postAction(this.url.chooseQuestionsPage, { scenario: 0, isPage: 1, postId: this.createRules.postId }).then(
(res) => {
let arr = res.result.records
for (var i = 0; i < arr.length - 1; i++) {
for (var j = i + 1; j < arr.length; j++) {
if (arr[i].affiliationId == arr[j].affiliationId) {
arr.splice(j, 1)
//因为数组长度减小1,所以直接 j++ 会漏掉一个元素,所以要 j--
j--
}
}
}
console.log('哈哈哈哈', arr)
this.QuestionsList = arr
}
)
JS数组根据某一属性去重
最新推荐文章于 2024-05-01 04:53:19 发布