Reputation: 83
import router from './router'
Vue.use(router)
new Vue({
el: '#app',
router,
template: '<App/>',
components: { App }
})
I have this piece of code in my main.js and in other file called index.js I have all the paths of the components. I would like to know how to remove the hash from the url. Any docs?? Im using webpack
Upvotes: 1
Views: 2647
Reputation: 7
In my version of Vue.Js, you will have to add the mode: 'history'
line for the new router.
Vue.use(Router)
export default new Router({
mode: 'history',
routes: [
...
]
})
Upvotes: 0
Reputation: 246
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.
Copied from the vue-router
document, we must configure the server (apache, nginx or others) to make sure the index.html
can be matched, or it will get 404.
Upvotes: 0
Reputation: 1125
Configure your router with mode = history
const router = new VueRouter({
mode: 'history',
routes: [...]
})
https://router.vuejs.org/en/essentials/history-mode.html
Upvotes: 4