Ant Design TreeSelect 单选模式下选择框消失问题解决
当TreeSelect组件设置为单选模式后,选择框会隐藏,因为单选模式下只能选择一个选项,不需要显示选择框。如果您想要显示选择框,可以将TreeSelect组件设置为多选模式,即设置'mode'属性为'multiple'。示例代码如下:
import { TreeSelect } from 'antd';
const treeData = [
{
title: 'Node 1',
value: '0-0',
children: [
{
title: 'Child Node 1',
value: '0-0-0',
},
{
title: 'Child Node 2',
value: '0-0-1',
},
],
},
{
title: 'Node 2',
value: '0-1',
},
];
function Demo() {
return (
<TreeSelect
treeData={treeData}
treeDefaultExpandAll
mode='multiple'
placeholder='Please select'
/>
);
}
export default Demo;
以上代码中,'mode'属性设置为'multiple',即可显示选择框。
原文地址: https://www.cveoy.top/t/topic/pczO 著作权归作者所有。请勿转载和采集!