通過用戶選擇的上下車點 挑選出匹配的線路let data=[
{ name:'a', line:[
{type:'up',place:'上車點一'},
{type:'up',place:'上車點二'},
{type:'up',place:'上車點三'},
{type:'down',place:'下車點一'},
{type:'down',place:'下車點二'}
]
},
{ name:'b', line:[
{type:'up',place:'上車點一'},
{type:'up',place:'上車點四'},
{type:'up',place:'上車點五'},
{type:'down',place:'下車點一'},
{type:'down',place:'下車點二'}
]
},
{ name:'c', line:[
{type:'up',place:'上車點二'},
{type:'down',place:'下車點一'},
{type:'down',place:'下車點二'}
]
},
]
let upName='上車點一'let downName='下車點二'循環(huán)data 按照upName 和 downName 挑選出合適的線路
不知道怎么循環(huán)出來
求教
data.forEach(function (item) {
item.line.forEach(function (val) { if(val.type==='up' && val.place===upName){
}
})
})
關(guān)于js數(shù)組匹配的問題
絕地?zé)o雙
2018-09-24 17:56:41