element-ui重置表單並清除校驗的方法


this.$refs['activityForm'].resetFields();

只會重置之前表單的內容,並不會清空

 

 

 

只需在關閉彈框的cancel方法中寫上重置表單的方法即可

cancel() {
      this.$refs.formData.resetFields();
   }

若首先編輯,會初始化值,再新增resetFields無效,需做如下處理:

modifyDeptDialog () {     
    
   let selectRow = this.$refs.table.store.states.currentRow
      this.dialogVisible = true      
      //回顯數據
      setTimeout(function () {
        this.saveDeptForm = deepClone(selectRow)
      }.bind(this), 0);          
    },

 或者

modifyDeptDialog () {

    let selectRow = this.$refs.table.store.states.currentRow
this.dialogVisible = true      
      //回顯數據
      this.$nextTick(()=>{
        this.saveDeptForm = deepClone(selectRow)
      })        
    },

 


免責聲明!

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



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