React-Cannot read property 'state' of undefined at handleClick 报错原因

react在新版本中,修改了对state的处理方式

解决办法:1.由于state设置在了作用域内部,引用时可以使用如代码20行的方式改变this指向修改state的值。


2.也可以使用setState设置


猜你喜欢

转载自blog.csdn.net/liuyahui_0126/article/details/80115171