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