【发布时间】:2020-10-25 21:46:23
【问题描述】:
我正在通过 axios 从 API 调用中获取 JSON,目前正在使用 vue 显示 JSON。
这是来自控制台的 JSON 对象:
0:
category_id: "categ1"
item_name: "item1"
price: 100
stock: 155
1:
category_id: "categ2"
item_name: "item2"
price: 100
stock: 155
2:
category_id: "categ1"
item_name: "item3"
price: 100
stock: 155
3:
category_id: "categ3"
item_name: "item4"
price: 100
stock: 155
这是我的 vue 挂载函数(我正在使用 axios):
mounted () {
axios.get('link_for_api_endpoint', {
headers : {
Authorization: 'Bearer ' + access_token,
},
params: {
limit: 250
}
})
.then((response) => {
this.data = response.data.items;
//console.log(response);
$("#ldr").hide();
removeLoader();
})
.catch(function (error) {
console.log(error);
})
.then(function () {
});
}
我想要做的是我只想获取具有类别值“categ1”的数据,而不是整个 json 对象。我如何做到这一点?
【问题讨论】:
-
jquery?为了什么?
标签: javascript vue.js axios