根据关键词匹配出树结构里节点
例如:
var tree = [
{
text: '设计',
children: [
{
text: 'UI设计',
children: [
{
text: '页面',
children: []
}
]
},
{
text: '平面设计',
children: [
{
text: '室内',
children: []
}
]
}
]
},
{
text: '数据统计',
children: [
{
text: '百度统计',
children: []
},
{
text: '数据分析',
children: [
{
text: '分析一',
children: []
},
{
text: '分析二',
children: []
},
{
text: '测试一',
children: []
}
]
}
]
}
];
// 输入
searchTreeData(tree, '测试');
// 输出
var res = [
{
text: '数据统计',
children: [
{
text: '数据分析',
children: [
{
text: '测试一',
children: []
}
]
}
]
}
];