elementUI form表单动态增加表单项使用v-for进行表单校验时报错,报错信息如下:
please transfer a valid prop path to form item!
主要原因是el-form-item的v-for内容要和绑定的prop名称对应上
<el-form-item
v-for="(rules, index) in form.rules"
:label="`键值${index + 1}`"
:key="index"
:prop="`rules.${index}`" :rules="{
required: true, message: 'value不能为空', trigger: 'blur'
}"
>
<el-input v-model="form.rules[index]" class="key-input"></el-input>
<el-button @click.prevent="removeRules(rules)">删除</el-button>
</el-form-item>