vue 監聽頁面退出,彈出確認退出提示


data () {
  return {
    // 退出確認
    backConfirm: true
  }
},
// 導航離開該組件的對應路由時調用
beforeRouteLeave (to, from, next) {
  if (this.backConfirm) {
    mui.confirm('數據未進行保存將會丟失,確認退出本頁面嗎?', '提示', ['否', '是'], function (e) {
      if (e.index == 1) {
        next(true);
      }
    })
  }
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM