Each child in an array or iterator should have a unique &
发布时间:2020-12-15 06:50:28 所属栏目:百科 来源:网络整理
导读:Each child in an array or iterator should have a unique "key" prop. Check the render method of ` Table Cell ` 在使用ant的过程中,我相信有很多人都会遇到这个错误, 解决方式需要根据不再的场景来,遵循的只有一个原则,设置key值, 在table中:需要设置ro
Each child in an array or iterator should have a unique "key" prop. Check the render method of `Table Cell` 在使用ant的过程中,我相信有很多人都会遇到这个错误, 解决方式需要根据不再的场景来,遵循的只有一个原则,设置key值, 在table中:需要设置rowKey,如果dataSource中没有id的话,需要设置rowKey的值指向唯一. 在option中也 需要设置key值的,比如:有一段数据 const menuItem = [ { value:'0',text:'项目出勤' },{ value:'1',text:'春节放假' },{ value:'2',text:'春节待命' },{ value:'3',text:'带薪假(婚/丧/探/亲)' },{ value:'4',text:'带薪病假' },{ value:'5',text:'事假' },{ value:'6',text:'旷工' },]; 在做循环的时候,需要设置key值,不然会报错,可以这样做, <Select style={{ width: 80 }} onChange={this.fatherSelectChange.bind(this)}> {menuItem.map((item,index) =>{ return( <Option key={index} value={item.value}>{item.text}</Option> ) })} </Select> 欢迎各界大神前来指导,有问题也可以在下方留言交流. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |