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