在登录页中
mounted() {
// 禁用浏览器返回键
history.pushState(null, null, document.URL);
window.addEventListener('popstate', this.disableBrowserBack)
},
destroyed() {
// 清除popstate事件 否则会影响到其他页面
window.removeEventListener("popstate", this.disableBrowserBack, false)
},
methods:{
disableBrowserBack() {
history.pushState(null, null, document.URL);
},
}