我能够根据键入内容搜索内容。但是父级有其子级组件,因此例如:
我正在尝试使用"c"
过滤内容,如果这样做,我会得到父级和1个孩子,但是在这里,我有2个子组件,一个是"Check"
,另一个是"check_test"
。
当我尝试使用字母“ c”进行过滤时,无论大小写敏感,我都必须同时获得两个子代。
TS:
searchFacility(search) {
this.sLetter = search;
if (search) {
this.dtFacilities.expandedRows = [];
setTimeout(() => {
this.dtFacilities.expandedRows = this.dtFacilities.value;
this.dtFacilities.value.forEach(m => {
m.memberFacilities.forEach(f => {
if (f.facilityName.includes(search)) {
f.isShowMember = false;
} else {
f.isShowMember = true;
}
})
})
}, 100);
}
else {
this.dtFacilities.expandedRows = [];
this.dtFacilities.value.forEach(m => {
m.memberFacilities.map(val => {
val.isShowMember = false;
})
})
}
}
在此部分
if (f.facilityName.includes(search)) {
f.isShowMember = false;
} else {
f.isShowMember = true;
}
})
对于搜索,它占用"c"
,因此通过将"Check"
isShowMember标志设为true来进行其他条件。
答案 0 :(得分:1)
let mySearch = search.toLowerCase();
let facilityName = f.facilityName.toLowerCase();
if (facilityName && facilityName.includes(search)) {
f.isShowMember = false;
} else {
f.isShowMember = true;
}
})