mirror of
https://github.com/ant-design/ant-design.git
synced 2025-08-06 07:56:28 +08:00
parent
7fe027bfcf
commit
b7879e909f
@ -90,7 +90,7 @@ class SearchTree extends React.Component {
|
||||
onChange = (e) => {
|
||||
const value = e.target.value;
|
||||
const expandedKeys = dataList.map((item) => {
|
||||
if (item.key.indexOf(value) > -1) {
|
||||
if (item.title.indexOf(value) > -1) {
|
||||
return getParentKey(item.key, gData);
|
||||
}
|
||||
return null;
|
||||
@ -104,16 +104,16 @@ class SearchTree extends React.Component {
|
||||
render() {
|
||||
const { searchValue, expandedKeys, autoExpandParent } = this.state;
|
||||
const loop = data => data.map((item) => {
|
||||
const index = item.key.indexOf(searchValue);
|
||||
const beforeStr = item.key.substr(0, index);
|
||||
const afterStr = item.key.substr(index + searchValue.length);
|
||||
const index = item.title.indexOf(searchValue);
|
||||
const beforeStr = item.title.substr(0, index);
|
||||
const afterStr = item.title.substr(index + searchValue.length);
|
||||
const title = index > -1 ? (
|
||||
<span>
|
||||
{beforeStr}
|
||||
<span style={{ color: '#f50' }}>{searchValue}</span>
|
||||
{afterStr}
|
||||
</span>
|
||||
) : <span>{item.key}</span>;
|
||||
) : <span>{item.title}</span>;
|
||||
if (item.children) {
|
||||
return (
|
||||
<TreeNode key={item.key} title={title}>
|
||||
|
Loading…
Reference in New Issue
Block a user