2.0.8 • Published 8 months ago

vanjs-router v2.0.8

Weekly downloads
-
License
-
Repository
-
Last release
8 months ago

vanjs-router

Simple Frontend Routing Component Based on Van.js.

This is version 2. For version 1 documentation, please click here.

Features

  • Supports both string and regex matching.
  • Supports setting page display delay.
  • Supports configuring events for the first route match (onFirst) and subsequent route matches (onLoad).
  • Implemented using TypeScript.
  • Simple API.

Quick Start

npm install vanjs-router
<script src="https://cdn.jsdelivr.net/npm/vanjs-router@latest/dist/vanjs-router.min.js"></script>
<script>
  const { Route, goto } = router;
  const { div, button } = van.tags;

  const Home = () =>
    Route({
      rule: "home",
      Loader() {
        return div(
          "This Is Home Page.",
          button({ onclick: () => goto("about") }, "Go To About")
        );
      },
      onFirst() {
        console.log("home onfirst");
      },
      onLoad() {
        console.log("home onload");
      },
    });

  const About = () =>
    Route({
      rule: "about",
      delayed: true,
      Loader() {
        return div(
          "This Is About Page.",
          button({ onclick: () => goto("home") }, "Go To Home")
        );
      },
      onLoad() {
        this.show();
      },
    });

  van.add(document.body, Home(), About());
</script>
2.0.8

8 months ago

2.0.7

10 months ago

2.0.3

12 months ago

2.0.2

12 months ago

2.0.5

11 months ago

2.0.4

12 months ago

2.0.6

11 months ago

2.0.1

12 months ago

2.0.0

12 months ago

1.2.0

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.1.2

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago