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

1.通过Function.prototype.bind()

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

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

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


3.通过箭头函数



全部评论

相关推荐

投递美团等公司10个岗位
点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务