How to remove hashbang #!
from url?
I found option to disable hashbang in vue router documentation ( http://vuejs.github.io/vue-router/en/options.html ) but this option removes #!
and just put #
Is there any way to have clean url?
Example:
NOT: #!/home
BUT: /home
Thanks!
"There is no way to clear the session history or to disable the back/forward navigation from unprivileged code. The closest available solution is the location. replace() method, which replaces the current item of the session history with the provided URL."
The default mode for vue-router is hash mode - it uses the URL hash to simulate a full URL so that the page won't be reloaded when the URL changes. To get rid of the hash, we can use the router's history mode, which leverages the history.
Vuex is a state management pattern + library for Vue. js applications. It serves as a centralized store for all the components in an application, with rules ensuring that the state can only be mutated in a predictable fashion.
You'd actually just want to set mode
to 'history'
.
const router = new VueRouter({ mode: 'history' })
Make sure your server is configured to handle these links, though. https://router.vuejs.org/guide/essentials/history-mode.html
For vue.js 2 use the following:
const router = new VueRouter({ mode: 'history' })
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With