Vue hash router plugin (with disabled back button)
Usage
Install in your VueJS project:
npm i -s tb-vue-hash-router
Import in main.js and install it with a landing page:
Vue Vue
All your pages should be globally installed in main.js!
In your root vue component:
And you are good to go!
API:
The default usage (with globally installed pages):
methods: { this // the page rendered in <page-root> is home-page.vue // hash is #home // back button still useless }
...or simply from the template:
Home
The param of $navigate function is always a string: the name of a globally registered page.
Full API:
// simple redirect without paramsthis // simple redirect with params - available in next page with $getRedirectParamsthis
// loads the redirect params (most likely in created() lifecycle method)/* in a page loaded with #products?id=5 the object { id: 5 } is available with $getRedirectParams*/let params = this
// adds ?id=5 to the hashthis // deletes query param id if existsthis // deletes all query paramsthis // updates multiple params to the hash: ?id=5&show=false// previous params deletedthis