美文网首页
关于el-form表单动态校验失效的问题

关于el-form表单动态校验失效的问题

作者: 扶得一人醉如苏沐晨 | 来源:发表于2022-11-19 18:04 被阅读0次

    注意官方提示是这种格式

    image.png

    为什么我们的prop为什么这样写

    :prop="'itemList.' + index + '.name'"
    

    或者使用模板字符串

    :prop="`itemList.${index}.name`"
    

    而不能这样写

    :prop="itemList[index].name"
    
      <el-form
                :model="dataForm"
                ref="dataForm"
                label-width="100px"
                class="demo-dynamic"
            >
    //切记切记!!!!!!!!!!!!!!
    //:prop="`itemList.${index}.name`"
    //或者:prop="'itemList.' + index + '.name'"
    //一定不能写成 :prop="itemList[index].name"
                <el-row v-for="(item, index) in dataForm.itemList" :key="index">
                    <el-col :span="20">
                        <el-form-item
                            :label="'规格' + index"
                            :prop="`itemList.${index}.name`"
                            :rules="dataRule.size"
                        >
                            <el-input
                                v-model="dataForm.itemList[index].name"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
    

    相关文章

      网友评论

          本文标题:关于el-form表单动态校验失效的问题

          本文链接:https://www.haomeiwen.com/subject/nthvxdtx.html