mdzz、、const声明的变量保持原引用。

this。setState会发现引用没有改变更改内部属性不会触发更新。

let picList: any = this.state.resumeImages;
picList = JSON.parse(JSON.stringify(picList))
if (picList[index]) {
picList[index].src = key;
} else {
picList.push({ src: key })
}
this.setState({
resumeImages: picList
})通过方法深拷贝一次就可以了。
这里推荐JSON.parse(JSON.stringify(picList))深拷贝,简单便捷

相关文章:

  • 2021-09-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-28
猜你喜欢
  • 2022-12-23
  • 2021-06-30
  • 2022-02-09
  • 2022-12-23
  • 2022-12-23
  • 2021-09-24
  • 2021-09-29
相关资源
相似解决方案