世界上最伟大的投资就是投资自己的教育
yang_ye
id 3052
见习 小学生
-
哦,懂了懂了,谢谢
-
哔哩哔哩 (゜-゜) つロ 干杯~-bilibili
-
视频里的
updateRecord(record, data) {
const recordIndex = this.state.records.indexOf(record);
const newRecords = this.state.records.map( (item, index) => {
if(index !== recordIndex) {
// This isn't the item we care about - keep it as-is
return item;
}// Otherwise, this is the one we want - return an updated value return { ...item, ...data }; }); this.setState({ records: newRecords });
}
自己写的
updateRecord(data, i) {
let records = [...this.state.records];
records[i] = {...record[i],...data};
this.setState({
records: records
})
}老大,视频里写的和我这样写的比,有什么好处吗,为什么要用 map 方法啊
© 汕尾市求知科技有限公司 | Rails365 Gitlab | Qiuzhi99 Gitlab | 知乎 | b 站 | 搜索
粤公网安备 44152102000088号 | 粤ICP备19038915号
Top