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>
    );
     
  • 相关阅读:
    .net软件开发工程师面试题
    html笔记
    好用软件
    谷歌插件
    vue笔记
    js笔记
    数组去重
    css全局样式
    css笔记
    vscod插件
  • 原文地址:https://www.cnblogs.com/michaelShao/p/9758826.html
Copyright © 2011-2022 走看看