报错截图:

Avoid mutating a prop directly since the value will be overwritten whenever the parent component……

报错原因:

官方解释: 所有的 prop 都使得其父子 prop 之间形成了一个单向下行绑定:父级 prop 的更新会向下流动到子组件中,但是反过来则不行。这样会防止从子组件意外改变父级组件的状态,从而导致你的应用的数据流向难以理解。

即在本项目中,子组件直接对 父组件的 current 进行了操作

解决办法:

定义一个本地的 data 属性并将这个 prop 用作其初始值,即需要在子组件中将 current 赋值给 currentNum, 再对 currentNum 进行操作

相关代码:

Avoid mutating a prop directly since the value will be overwritten whenever the parent component……

相关文章:

  • 2021-04-08
  • 2022-12-23
  • 2022-12-23
  • 2021-06-18
  • 2021-09-10
  • 2021-12-01
  • 2021-06-26
  • 2021-09-05
猜你喜欢
  • 2021-05-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-20
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案