vue elementui 頁面監控form表單數據變化


computed: {
      watchList: function() {
        const obj = {}
        Object.keys(this.good).forEach(key => {
          obj[key] = this.good[key]
        })
        return obj
      }
    },
    watch: {
      watchList: {
        deep: true,
        handler: function(newVal,oldVal) {
          if (newVal !== oldVal) {
            window.valueChange = true
          }
        }
      },
      '$route': function() {
        // 這里要加一個提示窗 提示沒有保存是否切換到其它頁面
        this.$refs['good'].clearValidate()
        this.$refs['good'].resetFields()
      }
    },
// 返回
      goBack() {
        if(this.good.name||this.good.remark){
            if (this.$route.query.type == 1) {
              this.text = '確定放棄編輯黑名單組嗎?'
            } else {
              this.text = '確定放棄新增黑名單組嗎?'
            }
            alert.goBack(this.text)
        }else{
           window.valueChange = false
          alert.goBack()
        }
      },

  


免責聲明!

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



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