React学习案例二十四

Posted hhh江月

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了React学习案例二十四相关的知识,希望对你有一定的参考价值。

React学习案例二十四

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




<!-- class LoggingButton extends React.Component 
  // 这个语法确保了 `this` 绑定在  handleClick 中
  // 这里只是一个测试
  handleClick = () => 
    console.log('this is:', this);
  
 
  render() 
    return (
      <button onClick=this.handleClick>
        Click me
      </button>
    );
  
 -->


<!-- class LoggingButton extends React.Component 
  // 这个语法确保了 `this` 绑定在  handleClick 中
  // 这里只是一个测试
  handleClick = () => 
    console.log('this is:', this);
  
 
  render() 
    return (
      <button onClick=this.handleClick>
        Click me
      </button>
    );
  
 -->


<!-- class LoggingButton extends React.Component 
  // 这个语法确保了 `this` 绑定在  handleClick 中
  // 这里只是一个测试
  handleClick = () => 
    console.log('this is:', this);
  
 
  render() 
    return (
      <button onClick=this.handleClick>
        Click me
      </button>
    );
  
 -->



<!-- class LoggingButton extends React.Component 
  // 这个语法确保了 `this` 绑定在  handleClick 中
  // 这里只是一个测试
  handleClick = () => 
    console.log('this is:', this);
  
 
  render() 
    return (
      <button onClick=this.handleClick>
        Click me
      </button>
    );
  
 -->



<!-- class LoggingButton extends React.Component 
  // 这个语法确保了 `this` 绑定在  handleClick 中
  // 这里只是一个测试
  handleClick = () => 
    console.log('this is:', this);
  
 
  render() 
    return (
      <button onClick=this.handleClick>
        Click me
      </button>
    );
  
 -->

以上是关于React学习案例二十四的主要内容,如果未能解决你的问题,请参考以下文章

React学习案例十四

React学习案例二十三

Python爬虫(二十四)_selenium案例:执行javascript脚本

React学习案例二十二

React学习案例二十八

React学习案例二十六