正常退出后在登录页时执行浏览器回退不进入项目内部

在登录页中

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);
    },


}

 

おすすめ

転載: blog.csdn.net/huhuhuja/article/details/115342556