【发布时间】:2019-01-09 19:15:01
【问题描述】:
我正在尝试在 VueJs 前端和 Spring 后端中使用 AXIOS 检索汽车制造商 ID。
在下面提供的代码中,我已经实现了这一点,但是一些 ID 重复(这是注定要发生的),问题是如何过滤掉重复的 ID?
下面是我的getMethod。
getMethod () {
AXIOS.get(`/url/`)
.then(response => {
if (response.status == 200) {
this.response = response.data
this.myTest = response.data.map(mesg => mesg.carManufacterId)
console.log(this.myTest)
}
},
(err) => {
if (err.response.status == 500) {
console.log('turned off')
}
else if (err.response.status == 404) {
console.log('Could not retrieve)
}
})
},
【问题讨论】:
-
相似但不重复
-
您的问题是“如何从数组中删除重复项?”,这与“如何获取数组中的唯一值?”相同。
标签: javascript vue.js vuejs2 axios