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)
      })        
    },

 

posted @ 2019-12-01 22:57  青春无敌小宇宙  阅读(10777)  评论(0编辑  收藏  举报