一、发生场景
在使用Ant Design 时,进入页面打开控制台发现有红色的警告:
‘Form.Item’ cannot generate ‘validateStatus’ and ‘help’ automatically,
while there are more than one ‘getFieldDecorator’ in it.
二、原因
经过查找发现在同一个form-item中使用v-for循环遍历生成了多个input框,并且每个都加上了v-decorator作为数组,但实际每一个from-item中只允许有一个v-decorator进行绑定。
三、解决办法
在v-for内要生成的要加v-decorator的元素(如input)外再包裹一层form-item,即对n个元素进行循环遍历将生成n个form-item,满足了一个form-item仅有一个v-decorator的要求,不再报错。