en-US
Search for options.
The search can be customized through dCustomSearch.
zh-CN
对选项进行搜索。
可通过 dCustomSearch 自定义搜索。
import { DCascader } from '@react-devui/ui';
const list = Array.from({ length: 3 }).map((_, index1) => ({
label: `Item ${index1}`,
value: `${index1}`,
children: Array.from({ length: 5 }).map((_, index2) => ({
label: `Item ${index1}-${index2}`,
value: `${index1}-${index2}`,
disabled: index2 === 3,
children: Array.from({ length: 20 }).map((_, index3) => ({
label: `Item ${index1}-${index2}-${index3}`,
value: `${index1}-${index2}-${index3}`,
})),
})),
}));
const search = {
filter: (value, item) => {
return item.label.endsWith(value);
},
sort: () => -1,
};
export default function Demo() {
return (
<>
<DCascader style={{ width: 200 }} dList={list} dPlaceholder="Search" dSearchable></DCascader>
<DCascader style={{ width: 200 }} dList={list} dPlaceholder="Custom search" dSearchable dCustomSearch={search}></DCascader>
</>
);
}