const arr = [
{
name:'第一层',
children:[
{name:'第一层的孩子',children:[name:'第二层的孩子']}
]
}
...
]
html...
javescript...
async searchCategory_name() {
if (this.category_name !== '') {
this.tableData = await this.searchData(this.cloneTableData, this.category_name);
}
},
searchData(data, val) {
return data.filter(function f(o) {
if (o.category_name.includes(val)) return true
if (o.children) {
return (o.children = o.children.filter(f)).length
}
})
},