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();
}
}