2 回答
TA贡献1853条经验 获得超9个赞
您只需要从return data地图的每次迭代中添加:
this.selectedList = [
[{
"meterNumber": "Z00001410",
"utilType": "elec",
"mprnGprn": "3100000334",
"isChecked": true
},
{
"meterNumber": "Z00001410",
"utilType": "gas",
"mprnGprn": "1000003344",
"isChecked": true
}
],
[{
"meterNumber": "Z00001410",
"utilType": "elec",
"mprnGprn": "1000003344",
"isChecked": true
}],
[{
"meterNumber": "Z00001410",
"utilType": "elec",
"mprnGprn": "1000003344",
"isChecked": true
}]
]
selectAll = () => {
this.newList = this.selectedList.map((data) => {
data.forEach(item => {item.isChecked = false});
return data;
});
console.log(this.newList);
}
selectAll()
TA贡献1993条经验 获得超5个赞
请记住,使用地图时需要返回一个值。这是一个可行的解决方案:
this.selectedList = [
[
{
"meterNumber": "Z00001410",
"utilType": "elec",
"mprnGprn": "3100000334",
"isChecked": true
},
{
"meterNumber": "Z00001410",
"utilType": "gas",
"mprnGprn": "1000003344",
"isChecked": true
}
],
[
{
"meterNumber": "Z00001410",
"utilType": "elec",
"mprnGprn": "1000003344",
"isChecked": true
}
],
[
{
"meterNumber": "Z00001410",
"utilType": "elec",
"mprnGprn": "1000003344",
"isChecked": true
}
]
]
selectAll = () => {
this.selectedList = this.selectedList.map(subArray => {
subArray.forEach(_ => _.isChecked = false);
return subArray;
});
console.log(this.selectedList)
}
selectAll();
添加回答
举报