使用vue开发webApp,安卓手机自带回退键的问题解决 - 流浪_光头 - 博客园

9530 人参与 | 时间:2024年03月15日 13:09:34
点击跳转 www.cnblogs.com
内容
mounted(){
  if (window.history && window.history.pushState) {
    history.pushState(null, null, document.URL);
    window.addEventListener('popstate', this.fun, false);//false阻止默认事件
  }
},
destroyed(){
window.removeEventListener('popstate', this.fun, false);//false阻止默认事件
},
methods:{
fun(){
console.log("监听到了");
}
}