a-tree-select
时间: 2023-11-30 15:40:54 浏览: 82
a-tree-select是一个ReactMUI组件,它允许用户从树形结构中选择一个选项。为了构建树,我们使用遵循点符号的层次结构字段,例如:L.L1将是大号L1。以下是一个使用a-tree-select的示例代码:
```jsx
import React, { useState } from 'react';
import { TreeSelect } from 'antd';
const treeData = [
{
title: 'Node1',
value: '0-0',
children: [
{
title: 'Child Node1',
value: '0-0-1',
},
{
title: 'Child Node2',
value: '0-0-2',
},
],
},
{
title: 'Node2',
value: '0-1',
},
];
const Demo = () => {
const [value, setValue] = useState(undefined);
const onChange = (newValue) => {
console.log('onChange:', newValue);
setValue(newValue);
};
return (
<TreeSelect
showSearch
style={{ width: '100%' }}
value={value}
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
placeholder="Please select"
allowClear
treeDefaultExpandAll
onChange={onChange}
treeData={treeData}
/>
);
};
export default Demo;
```
阅读全文