2016-09-01 11:08:41 +08:00
|
|
|
---
|
2016-12-22 16:23:33 +08:00
|
|
|
order: 8
|
2016-09-01 11:08:41 +08:00
|
|
|
title:
|
|
|
|
zh-CN: 搜索
|
|
|
|
en-US: Search
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
可以直接搜索选项并选择。
|
|
|
|
|
2017-03-29 15:39:10 +08:00
|
|
|
> `Cascader[showSearch]` 暂不支持服务端搜索,更多信息见 [#5547](https://github.com/ant-design/ant-design/issues/5547)
|
|
|
|
|
2016-09-01 11:08:41 +08:00
|
|
|
## en-US
|
|
|
|
|
|
|
|
Search and select options directly.
|
|
|
|
|
2017-03-29 15:39:10 +08:00
|
|
|
> Now, `Cascader[showSearch]` doesn't support search on server, more info [#5547](https://github.com/ant-design/ant-design/issues/5547)
|
|
|
|
|
2017-02-13 10:55:53 +08:00
|
|
|
````jsx
|
2016-09-01 11:08:41 +08:00
|
|
|
import { Cascader } from 'antd';
|
|
|
|
|
|
|
|
const options = [{
|
|
|
|
value: 'zhejiang',
|
2016-09-10 18:23:24 +08:00
|
|
|
label: 'Zhejiang',
|
2016-09-01 11:08:41 +08:00
|
|
|
children: [{
|
|
|
|
value: 'hangzhou',
|
2016-09-10 18:23:24 +08:00
|
|
|
label: 'Hangzhou',
|
2016-09-01 11:08:41 +08:00
|
|
|
children: [{
|
|
|
|
value: 'xihu',
|
2016-09-10 18:23:24 +08:00
|
|
|
label: 'West Lake',
|
2017-02-13 11:55:12 +08:00
|
|
|
}, {
|
|
|
|
value: 'xiasha',
|
|
|
|
label: 'Xia Sha',
|
|
|
|
disabled: true,
|
2016-09-01 11:08:41 +08:00
|
|
|
}],
|
|
|
|
}],
|
|
|
|
}, {
|
|
|
|
value: 'jiangsu',
|
2016-09-10 18:23:24 +08:00
|
|
|
label: 'Jiangsu',
|
2016-09-01 11:08:41 +08:00
|
|
|
children: [{
|
|
|
|
value: 'nanjing',
|
2016-09-10 18:23:24 +08:00
|
|
|
label: 'Nanjing',
|
2016-09-01 11:08:41 +08:00
|
|
|
children: [{
|
|
|
|
value: 'zhonghuamen',
|
2016-09-10 18:23:24 +08:00
|
|
|
label: 'Zhong Hua men',
|
2016-09-01 11:08:41 +08:00
|
|
|
}],
|
|
|
|
}],
|
|
|
|
}];
|
|
|
|
|
2016-12-07 10:43:06 +08:00
|
|
|
function onChange(value, selectedOptions) {
|
|
|
|
console.log(value, selectedOptions);
|
2016-09-01 11:08:41 +08:00
|
|
|
}
|
|
|
|
|
2018-03-09 00:47:38 +08:00
|
|
|
function filter(inputValue, path) {
|
|
|
|
return (path.some(option => (option.label).toLowerCase().indexOf(inputValue.toLowerCase()) > -1));
|
|
|
|
}
|
|
|
|
|
2016-09-01 11:08:41 +08:00
|
|
|
ReactDOM.render(
|
2016-09-13 11:51:34 +08:00
|
|
|
<Cascader
|
|
|
|
options={options}
|
|
|
|
onChange={onChange}
|
|
|
|
placeholder="Please select"
|
2018-03-09 00:47:38 +08:00
|
|
|
showSearch={{ filter }}
|
2016-09-13 11:51:34 +08:00
|
|
|
/>,
|
|
|
|
mountNode
|
|
|
|
);
|
2016-09-01 11:08:41 +08:00
|
|
|
````
|