当前位置:   article > 正文

EL-FROM动态添加item并设置必填_动态生成el-form-item

动态生成el-form-item
  1. <el-form ref="form" :model="form" :rules="rules" label-suffix=":" label-width="110px"
  2. label-position="center" size="mini">
  3. <el-button @click="add" type="primary">添加</el-button>
  4. <div v-for="(item,index) in form.arr" :key="index">
  5. <el-form-item label="部门" label-width="60px" :prop="'arr.'+index+'.dept'" :rules="rules.dept">
  6. <el-input v-model="item.dept" />
  7. </el-form-item>
  8. <el-form-item label="姓名" :prop="'arr.'+index+'.userName'"
  9. :rules="rules.userName">
  10. <el-input v-model="item.userName" />
  11. </el-form-item>
  12. <el-form-item label="工号" :prop="'arr.'+index+'.userNumber'" :rules="rules.userNumber">
  13. <el-input v-model="item.userNumber" />
  14. </el-form-item>
  15. </div>
  16. </el-form>
  1. rules: {
  2. edpt:[{required: true, message: "请输入部门", trigger: "blur"}],
  3. UserName:[{ required: true, message: "请输入姓名", trigger: "blur"}],
  4. UserNumber:[{ required: true, message: "请输入工号", trigger: "blur"}],
  5. }

效果

 

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

闽ICP备14008679号