mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-16 01:29:11 +08:00
1.1 KiB
1.1 KiB
order | title | ||||
---|---|---|---|---|---|
4 |
|
zh-CN
通过指定 options 里的 disabled
字段。
en-US
Disable option by specifying the disabled
property in options
.
import { Cascader } from 'antd';
import React from 'react';
interface Option {
value: string;
label: string;
disabled?: boolean;
children?: Option[];
}
const options: Option[] = [
{
value: 'zhejiang',
label: 'Zhejiang',
children: [
{
value: 'hangzhou',
label: 'Hangzhou',
children: [
{
value: 'xihu',
label: 'West Lake',
},
],
},
],
},
{
value: 'jiangsu',
label: 'Jiangsu',
disabled: true,
children: [
{
value: 'nanjing',
label: 'Nanjing',
children: [
{
value: 'zhonghuamen',
label: 'Zhong Hua Men',
},
],
},
],
},
];
const onChange = (value: string[]) => {
console.log(value);
};
const App: React.FC = () => <Cascader options={options} onChange={onChange} />;
export default App;