今天爱分享给大家带来React 事件处理程序 this undefined 如何处理【方法总结】 ,希望能够帮助到大家。
React 中,事件处理程序中,默认情况下,this为 undefined ,如果使用 this ,可以使用如下方法
第一种:
绑定事件处理程序时,使用bind方法绑定this
如:
第二种:
construtor() 方法中,使用 bind 方法绑定 this
construtor () {
super();
this.addComment = this.addComment.bind(this)
}
第三种:
使用箭头函数,来定义事件处理程序
addComment = ()=>{
}
第四种:
原文链接:https://blog.itblood.com/963.html,转载请注明出处。

![精神控制!~将纯洁无瑕的少女堕落成淫乱自慰女友为止V1.30 官方中文版[新官中][1.8G] [触摸互动SLG/汉化/动态]](/wp-content/uploads/replace/2025/10/03/36ae7d45585cfe632062ee5f8912d55b.webp)