当前位置:   article > 正文

Element-ui 之 form表单套数组、表单数组套数组的校验rules_elementui表单数组校验

elementui表单数组校验
  1. <el-form ref="form" :model="form" :rules="rules1" label-width="90px">
  2. <template v-if="form.arr1 && form.arr1.length">
  3. <div v-for="(item1, index1) in form.arr1" :key="index1">
  4. <!-- 数组嵌套数组 -->
  5. <el-row :gutter="32" v-for="(item2, index2) in item1.arr2" :key="index2">
  6. <el-col :span="10">
  7. <el-form-item label="嵌套数组" :rules="rules2.content1" :prop="`arr1[${index}1].arr2[${index2}].content1`">
  8. <el-input v-model="item2.content1" placeholder="请输入" />
  9. </el-form-item>
  10. </el-col>
  11. </el-row>
  12. <!-- 单个 -->
  13. <el-form-item label="单个1" :prop="`arr1[${index1}].content1`" :rules="rules1.content1">
  14. <el-input v-model="item1.content1" placeholder="请输入" />
  15. </el-form-item>
  16. <el-form-item label="单个2" :prop="`arr1[${index1}].content2`" :rules="rules1.content2">
  17. <el-input v-model="item1.content2" placeholder="请输入" />
  18. </el-form-item>
  19. </div>
  20. </template>
  21. </el-form>

  1. rules1: {
  2. conten1: [{
  3. required: true,
  4. message: 'XXX不能为空',
  5. trigger: 'blur'
  6. }],
  7. },
  8. rules2 {
  9. conten1: [{
  10. required: true,
  11. message: 'XXX不能为空',
  12. trigger: 'blur'
  13. }],
  14. },

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/112929
推荐阅读
相关标签
  

闽ICP备14008679号