项目上遇到this.$set 会跳出循环的情况

问题先记录下来,后续更新原因

closeFlowTag (index, item) {
this.reportUseList.splice(index, 1)
this.thirdList.forEach((obj) => {
let flow = obj.reportList.find((value, index, arr) => {
return value.reportId === item.reportId
})
this.$set(flow, 'commonFlag', 'N')
})
},

这种情况下,flow无论有没有循环到值,都会走this.$set,走this.$set就会直接跳出循环,导致该循环只会走一次

改成下面这种情况就好了

closeFlowTag (index, item) {
this.reportUseList.splice(index, 1)
this.thirdList.forEach((obj) => {
let flow = obj.reportList.find((value, index, arr) => {
return value.reportId === item.reportId
})
if (flow) {
this.$set(flow, 'commonFlag', 'N')
}
})
},

this.$set会直接跳出循环的原因:

posted on 2020-08-06 21:57  走出一条开花的路  阅读(238)  评论(0)    收藏  举报