Vue路由模式及监听

当然详细情况还是看一下vue的官网吧
官网https://router.vuejs.org/zh/
 
hash模式下(默认)
new VueRouter({
mode : ‘hash’,
routes : []
})
window.addEventListener(‘hashchange’,方法名或方法)
history模式
不会有#,但需要后端支持,这样每次刷新页面都会发送请求
new VueRouter({
mode : ‘history’,
routes : []
})
window.addEventListener(‘popstate’,方法名或方法)

猜你喜欢

转载自www.cnblogs.com/katydids/p/9944640.html