如图所示,店铺给的是ID,需要把ID换成另一个接口数据中相对应的值
另一个接口数据返回格式
"info": [
{
"id": 1, //ID
"name": "美妆海外购旗舰店", //名称
},
{
"id": 2, //ID
"name": "美妆海外购旗舰店", //名称
}
] //返回内容
//店铺下拉列表
storeDown() {
request({
url: "api/shop/getShopList",
method: "POST",
data: {},
}).then((res) => {
this.storeDownList = res.info
console.log('this.storeDownList', this.storeDownList)//下拉列表数据
})
},
//查询列表
getList() {
request({
url: "api/goodsExamine/list",
method: "POST",
data: this.listQuery,
}).then(data => {
this.list = data.info.content;
for (var i = 0; i < this.list.length; i++) {
var selectedName = {};
selectedName = this.storeDownList.find((item)=>{
if(item.id == this.list[i].shopId) {
console.log('item.id',item.id)
}
//筛选出匹配数据,是对应数据的整个对象
});
// selectedName =this.storeDownList.forEach(v => {
// if (v.id == this.list[i].shopId) {
// this.tempUser.shopId=v.name
// console.log('item.id',v.name)
// }
// })
}
console.log('this.list', this.list)//图中四组数据
console.log('selectedName', selectedName)//undefined
})
},