element关闭模态框清空表单验证
作者:互联网
1.点模态框右上角X关闭,不要用close或before-close属性,因为没办法传参,用@close事件
2.如果报错’resetFields’ of undefined,加一步判断:
if (this.$refs[formRule] !== undefined) {
this.$refs[formRule].resetFields();
}
代码整理:
//点右上角的X
@close="closeModel('modelForm')"
//点自定义的按钮
<el-button @click="closeModel('modelForm')">取消</el-button>
//方法
closeModel(formRule) {
this.createModel = false;
if (this.$refs[formRule] !== undefined) {
this.$refs[formRule].resetFields();
}
}
标签:模态,undefined,formRule,resetFields,refs,表单,closeModel,close,element 来源: https://blog.csdn.net/yoko0831/article/details/122308342