mounted() {
// 如果支持 popstate (一般移动端都支持)
if (window.history && window.history.pushState) {
// 往历史记录里面添加一条新的当前页面的url
history.pushState(null, null, document.URL);
// 给 popstate 绑定一个方法 监听页面刷新
window.addEventListener('popstate', this.backNative, false); //false阻止默认事件
}
},
destroyed() {
window.removeEventListener('popstate', this.backNative, false); //false阻止默认事件
},
methods: {
backNative() {
console.log("监听到了");
this.$router.push({
name: this.nineUrl
})
}
}

posted on 2020-09-30 17:26  Charonっ  阅读(661)  评论(0编辑  收藏  举报