Vue 禁用浏览器的前进后退操作
在main.js中,增加popstate监听
mounted(){
window.addEventListener('popstate', this.popstate)
}
beforeDestroyed() {
// 清除popstate事件
window.removeEventListener("popstate", this.popstate)
},
methods:{
popstate(){
history.pushState(null, null, document.URL)
}
},