项目上遇到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会直接跳出循环的原因:
浙公网安备 33010602011771号