【发布时间】:2018-11-16 17:23:17
【问题描述】:
我使用 vue-multiselect 让用户选择带有过滤选项的项目:
query = "what user type in input field"
allLinks.filter(l=>l.labelName.includes(query))
它可以工作,但现在我想用这种结构将过滤扩展到我的对象的所有属性:
{
"labelName":"LK000056",
"extPort":{
"aPort":"EXTA-EQ001/board10port02",
"zPort":"EXTZ-EQ012/board09port02"
}
}
如果 labelName、aPort 或 zPort 上的查询匹配,我希望使用一个查询来获取父对象。
有可能吗?或者可能使用有条件的方式,例如:
allLinks.filter(l=>if(!l.labelName.includes(query)){l.extport.aPort.includes(query)}else{l.extport.zPort.includes(query)})
谢谢你帮助我
请原谅我的近似英语我是法国人
【问题讨论】:
标签: javascript arrays filter nested multi-select