2.0.8 • Published 9 months ago

vanjs-router v2.0.8

Weekly downloads
-
License
-
Repository
-
Last release
9 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

9 months ago

2.0.7

11 months ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.5

1 year ago

2.0.4

1 year ago

2.0.6

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.2.0

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years 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