Form 组件提供了表单验证的功能,只需要通过rules
属性传入约定的验证规则,并将 Form-Item 的prop
属性设置为需校验的字段名即可。
当需要动态增加、减少校验字段时,处理方式为:
<el-form-item
class="content"
:prop="'content.'+index+'.content'"
v-for="(item,index) in DATA"
:rules="{ required: true, message: 'Content cannot be empty!', trigger: 'blur'}">
</el-form-item>
重点::prop="'content.'+index+'.content'"