【发布时间】:2019-11-14 17:33:51
【问题描述】:
如何使用两个字符串(搜索框)动态过滤数组值?到目前为止,这是我尝试过的:
if (!!this.searchCompany.toLowerCase() || !!this.searchName.toLowerCase()) {
this.filter = true
this.newval = this.list.filter(post => {
if (!!this.searchCompany.toLowerCase()) {
return post.profile.company ? post.profile.company.toLowerCase().includes(this.searchCompany.toLowerCase()) : null
} else if (!!this.searchName.toLowerCase()) {
return post.profile.full_name.toLowerCase().includes(this.searchName.toLowerCase())
} else {
return post
}
})
this.searchCompany 和 this.searchName 是我表单中的搜索框。
this.list
的数组内容【问题讨论】:
-
请添加您的
input array。
标签: javascript arrays filter include tostring