多级 v-for form表单校验

 以下为一层嵌套

<el-form-item v-for="(item,itemIndex) in form.button" :key="item.itemIndex" label="一级菜单" > <el-form-item :prop="'button.'+ itemIndex + '.name'" :rules="rules.inputTxt"> <el-input v-model="item.name" style="width:200px;"></el-input> </el-form-item> </el-form-item>

 

 

以下为两层,承接上一层的循环

<div v-for="(button,index) in item.sub_button" :key="button.index"> <el-form-item :prop="'button.'+ itemIndex +'.sub_button.'+ index + '.name'" :rules="rules.inputTxt" > <el-input v-model="button.name" style="width:200px;"></el-input> </el-form-item> <el-form-item :prop="'button.'+ itemIndex +'.sub_button.'+ index + '.key'" :rules="rules.inputTxt" > <el-input v-model="button.key" style="width:200px;"></el-input> </el-form-item> </el-form-item>

posted @ 2020-11-04 09:41  泽泽生龙  阅读(435)  评论(0编辑  收藏  举报