Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
568 views
in Technique[技术] by (71.8m points)

饿了么ui组件,form表单校验数组对象的问题

使用rules做必填校验时,因为表单是动态的,所以是循环渲染的,所以对应的绑定的数据也是一个数组,但饿了么ui组件又需要我们传入的数据是对象。这种有什么方法解决吗

Invalid prop: type check failed for prop "model". Expected Object, got Array


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

可以参考文档示例

<el-form-item
  v-for="(domain, index) in dynamicValidateForm.domains"
  :label="'域名' + index"
  :key="domain.key"
  :prop="'domains.' + index + '.value'"
  :rules="{
      required: true, message: '域名不能为空', trigger: 'blur'
    }"
>
  <el-input v-model="domain.value"></el-input><el-button @click.prevent="removeDomain(domain)">删除</el-button>
</el-form-item>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...