我正在尝试找出如何修复以下esLint错误
‘赋值给函数参数的属性。eslint(无参数-重新赋值)’
到目前为止,以下是我的代码
myArray.records.map(record =>
record.subRecords.map(subRecord => (
subRecord.transId = this.getIdCorrection(subRecord.transId)
))
))我尝试使用cloneDeep并为map创建另一个副本,然后重新分配,错误就在那里。
我读了一些帖子,但我搞不懂他们是如何使用过滤器的。
我正在传递一个整数值,它根据一些业务规则传递一个整数。
我不知道怎么才能通过这次考试。
谢谢
发布于 2020-01-24 03:56:07
ESLint可能希望您创建并返回一个新对象。请记住,map不是用来改变数组元素的,它是用来创建一个新的项数组的。
const newRecords = myArray.records.map(record => ({
...record,
subRecords: record.subRecords.map(subRecord => ({
...subRecord,
transId: this.getIdCorrection(subRecord.transId)
})
}))https://stackoverflow.com/questions/59886095
复制相似问题