用id数组去对象数组寻找id对应的对象
var tabbar = [{id:'1',name:'张三'},{id:'2',name:'李四'},{id:'3',name:'小赵'}];
var ids=['1','2'];//id数组
var selected_tab=[];//临时定义数组,用来存数据
var selected = [];//最终结果
ids.map(function (item) {
selected_tab=tabbar.filter(function (obj) {
return obj.id == item
});
selected.push(Object.assign({},...selected_tab))
})
console.log(selected); // 打印结果为[{id:'1',name:'张三'},{id:'2',name:'李四'}]