React中事件绑定this指向的三种方式

1.通过Function.prototype.bind()

(1)在react实例的构造函数constructor中通过es5中的bind函数绑定this

(2)在render函数的组件中直接通过bind绑定事件的this

2.通过箭头函数方式的class实例方法


3.通过箭头函数



全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务