一,在 created中 注册 页面刷新和关闭事件
created() {
 window.addEventListener('beforeunload', e => this.test(e))
}
 
二,事件,将你的逻辑方法加进去
methods: {
 test(e) {
  console.log('刷新或关闭')
  // ...
 }
}
三,卸载注册的事件
destroyed() {
 window.removeEventListener('beforeunload', e => this.test(e))
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-11
  • 2022-12-23
  • 2022-12-23
  • 2021-10-01
  • 2022-12-23
  • 2021-10-09
相关资源
相似解决方案