在同一个form-item中使用v-for循环遍历生成了多个select框(其他可循环展示的控件都是同样的问题),并且每个都加上了v-decorator作为数组,但实际每一个from-item中只允许有一个v-decorator进行绑定。
解决方案:
- 在v-for内要生成的要加v-decorator的元素(如input)外再包裹一层form-item,即对n个元素进行循环遍历将生成n个form-item,满足了一个form-item仅有一个v-decorator的要求,不再报错。
- 使用select组建时的解决方案是在最外层
a-select
中使用v-decorator
代码如下:
<a-select style="width:300px;" v-decorator="['id', {initialValue: '1'}]">
<a-select-option v-for="item of userId" :key="item">
{{ item }}
</a-select-option>
</a-select>