element-ui重置resetFields()不生效的解决
作者:禾火r
本文主要介绍了element-ui重置resetFields()不生效的解决,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
初始化数据
data() {
return {
dialogVisible: false,
form: {
name: '',
age: '',
sex: '',
birth: '',
addr: ''
}
}
}
弹窗关闭重置数据
handleClose() {
// 弹窗关闭的时候清除数据
this.$refs.form.resetFields()
this.dialogVisible = false
}
以上操作this.$refs.form.resetFields()未生效 直接强制变值,死马当活马医
初始化数据
data() {
return {
dialogVisible: false,
form: {
name: '',
age: '',
sex: '',
birth: '',
addr: ''
},
resetForm: {
name: '',
age: '',
sex: '',
birth: '',
addr: ''
}
}
}
弹窗关闭重置数据
handleClose() {
// 弹窗关闭的时候清除数据
this.form = this.resetForm
this.dialogVisible = false
}到此这篇关于element-ui重置resetFields()不生效的解决的文章就介绍到这了,更多相关element重置resetFields()不生效内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
