您的位置:首页 > Web前端 > React

如何解决Uncaught TypeError: this.setState is not a function

2017-02-23 17:50 936 查看
如何解决Uncaught TypeError: this.setState is not a function?

解决办法:在执行this.setState这条语句时的上一层函数末尾加上.bind(this);

举个例子:

reader.onload = function(e) {

this.setState(...);

}.bind(this)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  react this setState
相关文章推荐