当前位置: 代码迷 >> 综合 >> vue禁用浏览器返回键
  详细解决方案

vue禁用浏览器返回键

热度:59   发布时间:2024-02-09 11:45:39.0
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);}
}

 

  相关解决方案