
<template v-for="(person,index) in Form.List">
<el-form-item :prop="'List.'+index + '.code'" :key="person.key" :rules="rules">
<el-input v-model="person.code"></el-input>
</el-form-item>
<el-form-item prop="name">
<el-input v-model="person.name"></el-input>
</el-form-item>
<el-button @click="removeDomain(index)" size="small">-</el-button>
</template>
el-form-item 里面的循环prop名字,需要 和form中list的名字一致,这样才能确保组件的统一性
prop 中的值千万不要用点号,点具有特殊含义,会进行对象下级查找


本文介绍如何在 Vue 中使用 Element UI 的 El-Form 组件时,通过 v-for 循环动态绑定 List 中的对象,确保 prop 名称与列表元素保持一致,并避免点号在 prop 中的特殊含义。同时,探讨了组件的统一性和规则管理的最佳实践。
1534

被折叠的 条评论
为什么被折叠?



