当添加和修改复用一个表单时,vue不能动态监听对象的变化
清空方法(推荐使用方法3 || 4)
1.清空表单
在el-dialog标签中加上 @close="resetFormClosed"
//例如
<el-dialog title="新增" :visible.sync="dialogFormVisible" @close="closedForm">
<el-form :model="data" ref="form">
</el-form>
</el-dialog>
closedForm( ){
this.$refs.form.resetFields()
}
2.强制刷新
this.form.name=" "
this.$forceUpdate()
3.将表单里面的值变为空
closedForm(){
for(let key in this.data){
this.$set(this.data, key , “ ”)
}
}
4.将表单清空
closedForm(){
this.form={ }
}