【发布时间】:2018-08-02 08:02:07
【问题描述】:
我有这个从 API 获取数据的方法,它会向我发送许多家具的信息:
loadPieces() {
this.isLoading = true;
axios.get(this.galleryRoute)
.then(r => {
this.gallery = r.data;
this.isLoading = false;
})
.catch(error => {
this.$nextTick(() => this.loadPieces());
});
console.log(this.galleryRoute);
},
这是我得到的响应的一部分,只代表一个部分:
[[{"id":266,"name":" Tray 7x45x32, white stained ash","thumbnail":{"width":840,"height":840,"urls":{"raw":"http:\/\/localhost:8888\/storage\/9c\/9d\/9c9dadc6-15a2-11e8-a80a-5eaddf2d1b4a.jpeg","small":"http:\/\/localhost:8888\/storage\/9c\/9d\/9c9dadc6-15a2-11e8-a80a-5eaddf2d1b4a@140.jpeg","medium":"http:\/\/localhost:8888\/storage\/9c\/9d\/9c9dadc6-15a2-11e8-a80a-5eaddf2d1b4a@420.jpeg"}}},
现在我想创建一个过滤器,以便我可以使用它的 id 从 JSON 对象中获取特定的片段。我已经尝试过搜索,但到目前为止我不知道该怎么做。
提前致谢!
【问题讨论】:
-
有点不清楚,你在问什么。能否请你提供你以前的尝试?也许这可以帮助stackoverflow.com/questions/41791482/filter-list-with-vue-js/…