zoukankan      html  css  js  c++  java
  • React学习之事件绑定

    React事件绑定有主要有三种方式

    第一种官方推荐方式:

    class LoginControl extends React.Component {

      constructor(props) {
        super(props);
        this.handleLoginClick = this.handleLoginClick.bind(this);
      }
    }
     
    第二种官方简写方式:
    return (
     <button onClick={this.handleClick.bind(this)}>ES6方式创建的组件</button>
    );
     
    第三种箭头函数方式:是我个人比较喜欢的方式
    return (
     <button onClick={e => this.handleClick(e)}>ES6方式创建的组件</button>
    );
     
  • 相关阅读:
    CSS选择器
    CSS样式与语法
    实训第二天
    初学前端
    html-路径和图像标签
    html
    JavaScript(基础)
    CSS(2)
    CSS()
    HTML(链接与表单)
  • 原文地址:https://www.cnblogs.com/michaelShao/p/9758826.html
Copyright © 2011-2022 走看看