1.<el-dialog>下面的<el-form>添加rules验证后再次点开,验证已经启用
需要在el-dialog关闭的时候重置下窗体,重点代码为
@close="$reset('noticeInfoForm')"
例子如下:
<el-dialog
:close-on-click-modal="false"
width="70%"
:before-close="dialogClose"
:title="title"
:visible.sync="noticeDialogVisible"
@close="$reset('noticeInfoForm')"
>
<el-form ref="noticeInfoForm" :model="notice" label-width="100px" :rules="rules">
<el-form-item label="xxx" prop="title">
</el-form-item>
<el-form-item size="small" label="xxx" prop="content">
</el-form-item>
</el-form>
</el-dialog>
//rules定义在data()中
rules: {
title: [
{ required: true, message: '请输入标题', trigger: 'blur' },
],
content: [
{ required: false, message: '请输入内容', trigger: 'blur' },
],
},
网友评论