怎么能判断this.specialSafetymanaEvaluationRecordsChildList中是否存在传入的workUuid,如果不存在就把数据加进去,存在就把数据更新
this.specialSafetymanaEvaluationRecordsChildLis的结构:
this.specialSafetymanaEvaluationRecordsChildList.forEach((item,index) =>{
if (item.workUuid == workUuid) {
item.evaluationScore = thisScore;
}
})
let item = this.specialSafetymanaEvaluationRecordsChildList.find(item => item.workUuid == workUuid)
item ? (item.evaluationScore = thisScore) : this.specialSafetymanaEvaluationRecordsChildList.push({evaluationScore: thisScore, workUuid: workUuid})
http://www.noobyard.com/article/p-apfxktln-dy.html 如果有帮助到你的话,请采纳