0


React学习案例二十四

React学习案例二十四

  1. classLoggingButton extends React.Component {// 这个语法确保了 `this` 绑定在 handleClick 中
  2. // 这里只是一个测试
  3. handleClick =()=>{
  4. console.log('this is:', this);}
  5. render(){return(<button onClick={this.handleClick}>
  6. Click me
  7. </button>);}}<!--classLoggingButton extends React.Component {// 这个语法确保了 `this` 绑定在 handleClick
  8. // 这里只是一个测试
  9. handleClick =()=>{
  10. console.log('this is:', this);}
  11. render(){return(<button onClick={this.handleClick}>
  12. Click me
  13. </button>);}}--><!--classLoggingButton extends React.Component {// 这个语法确保了 `this` 绑定在 handleClick
  14. // 这里只是一个测试
  15. handleClick =()=>{
  16. console.log('this is:', this);}
  17. render(){return(<button onClick={this.handleClick}>
  18. Click me
  19. </button>);}}--><!--classLoggingButton extends React.Component {// 这个语法确保了 `this` 绑定在 handleClick
  20. // 这里只是一个测试
  21. handleClick =()=>{
  22. console.log('this is:', this);}
  23. render(){return(<button onClick={this.handleClick}>
  24. Click me
  25. </button>);}}--><!--classLoggingButton extends React.Component {// 这个语法确保了 `this` 绑定在 handleClick
  26. // 这里只是一个测试
  27. handleClick =()=>{
  28. console.log('this is:', this);}
  29. render(){return(<button onClick={this.handleClick}>
  30. Click me
  31. </button>);}}--><!--classLoggingButton extends React.Component {// 这个语法确保了 `this` 绑定在 handleClick
  32. // 这里只是一个测试
  33. handleClick =()=>{
  34. console.log('this is:', this);}
  35. render(){return(<button onClick={this.handleClick}>
  36. Click me
  37. </button>);}}-->

本文转载自: https://blog.csdn.net/m0_54218263/article/details/122821726
版权归原作者 hhh江月 所有, 如有侵权,请联系我们删除。

“React学习案例二十四”的评论:

还没有评论