* js禁用浏览器后退按钮
* vue中使用
*/
methods:{
goBack(){
history.pushState(null,null,document.URL);
},
}
destroyed(){
//路由跳转的时候,销毁监听,防止死循环
window.removeEventListener("popstate",this.goBack,false);
}
mounted(){
if(window.history && window.history.pushState){
history.pushState(null,null,document.URL);
window.addEventListener("popstate",this.goBack,false);
}
}
vue中使用,js禁用浏览器后退按钮
最新推荐文章于 2023-06-13 11:12:18 发布