vue禁止后退,并做相应的操作
mounted() {
if (window.history && window.history.pushState) {
history.pushState(null, null, document.URL);
window.addEventListener('popstate', this.goBack, false)
}
},
destroyed () {
window.removeEventListener('popstate', this.back, false)
},
methods: {
back () {
const that = this;
let needCofirmRouter = ['/'];
console.log(document.URL.split('#')[1]);
history.pushState(null, null, null);
if (needCofirmRouter.indexOf(document.URL.split('#')[1]) > -1) {
if (that.isPlayShow) {
that.isPlayShow = false;
} else {}
}
}
}