风华正茂、时光流逝、真爱时光、努力创建辉煌。

【react】事件绑定问题

 

1、react当中事件绑定不准确的解决办法。

class LoggingButton extends React.Component { handleClick() { console.log('this is:', this); } render() { // 这个语法确保了 `this` 绑定在 handleClick 中 return ( <button onClick={(e) => this.handleClick(e)}> Click me </button> ); } }

 

posted @ 2019-10-08 19:07  野马,程序源改造新Bug  阅读(73)  评论(0编辑  收藏  举报