hello-router
v1.0.0
Published
client-side router for SPA
Downloads
1
Readme
hello-router
client-side router for SPA
Install
npm install hello-router
API
- .register(uri, action)
- .activate(uri)
- .dispatch(uri)
- .redirect(uri)
- .run()
Usage
var router = helloRouter;
router.register('/a', function () {
// do something
router.redirect('/b');
// ignore follow code
});
router.register('/b', function () {
// do something
router.dispatch('/404');
// ignore follow code
});
router.register('/404', function () {
// do something
});
router.run();
// <a href="/hello/router?age=1"></a>
$('a').click(function () {
router.active(this.href);
return false;
});