使用element ui 写表单时, 常使用rules定义规则 面对 增加修改使用同一个弹框的场景 容易导致rules提示文字不清除 这时候需要 定义diolog弹框关闭事件 :before-close=“关闭弹窗事件” 并给form表单命名为edit 然后在关闭弹窗的事件中使用 this.$refs.edit.clearValidate() 并且置空数据即可
在这里插入代码片
```<el-dialog :title="dialogTitle" width="1000px" :before-close="closeLayer" :visible.sync="dialogVisible" append-to-body>
<el-form class="edit-form" ref="edit" :model="formAdd" :rules="rules"></el-form>
</el-doalog>
closeLayer() {
this.$refs.edit.clearValidate()
this.formAdd = {}
}