zoukankan      html  css  js  c++  java
  • react 事件绑定传参

    react中事件绑定需要用到onClick来绑定点击事件。

    一般直接写:

      handleSubmitForm  = e => {
        // 方法内处理
      }
              
      // render方法
    
      <Button onClick={this.handleFunction} >上一步</Button>

    当需要传参时,有两种写法,如下:

                  handleGuide = (item) => {
              // 内部方法,处理数据
            }


    // render 方法
              this.oprateListNew2.map((item,index)=>( <div key={index} onClick={this.handleGuide.bind(this, item)} // 方法1 // onClick={() => this.handleGuide(item)} // 方法2 > <Tag color="#E59104" style={{ position: 'absolute', top: 0,left: 0 }} >{index>4?'待上线':'已上线'}</Tag> <h4 style={{color: '#fff'}}>{item.title}</h4> </div> ))
  • 相关阅读:
    linux笔记
    ui转化为py
    stl学习
    React第一课
    React 第一课
    创建一个类
    nodejs基本语法
    let和const
    qml_status笔记
    controller层的单元测试
  • 原文地址:https://www.cnblogs.com/xguoz/p/12324943.html
Copyright © 2011-2022 走看看