antd treeselect发行'警告:树上存在相同的“值”:未定义'
我的Treeselect组件发出警告:树上存在相同的“值”:未定义的
警告但正确起作用,这是什么意思,我如何摆脱它?
const treeData = {
id: 1,
title: '1',
children: [{
id: 2,
title: '2',
parent_id: '1'
}]
}
//-------
<Form.Item
label={label}
name={name}
>
<AntdTreeSelect
treeDataSimpleMode
treeData={treeData}
/>
</Form.Item>
我正在使用ANTD 4.16.3
My TreeSelect component issuing a Warning: Same 'value' exist in the tree: undefined
warning but works correctly, what does that mean and how do I get rid of it?
const treeData = {
id: 1,
title: '1',
children: [{
id: 2,
title: '2',
parent_id: '1'
}]
}
//-------
<Form.Item
label={label}
name={name}
>
<AntdTreeSelect
treeDataSimpleMode
treeData={treeData}
/>
</Form.Item>
I'm using antd 4.16.3
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明,当使用
treedatasimplemode
prop时,treetElect期望对数据具有一定的结构,应该有一个pid
指向父级,而treedata prop应该是平坦的阵列组件本身将从id
和pid
s构建层次结构,因此将treedata更改为:将解决问题;或者,您也可以向
treedatasimplemode
prop:Note 提供有关您的结构的提示。 >,您必须在数据中具有
value
属性,但是您的数据结构可以是平坦的或树,它可以工作的任何一种方式Turns out when using
treeDataSimpleMode
prop, the TreeSelect expect a certain structure to the data, there should be apId
pointing to a parent id and the treeData prop should be a flat array the component itself will build the hierarchy fromid
andpId
s, so changing the treeData to:will solve the problem; or alternatively you can give hints about your structure to the
treeDataSimpleMode
prop:Note this is only limited to
id
andpid
, you have to have avalue
property in your data, but your data structure can be flat or tree, it works either way