Vue路由模式及监听

92 阅读1分钟
hash模式下(默认)
new VueRouter({
mode : ‘hash’,
routes : []
})
window.addEventListener(‘hashchange’,方法名或方法)

history模式
不会有#,但需要后端支持,这样每次刷新页面都会发送请求
new VueRouter({
mode : ‘history’,
routes : []
})


window.addEventListener(‘popstate’,方法名或方法)