为了账号安全,请及时绑定邮箱和手机立即绑定

React jsx 怎么在回调中增加参数

React jsx 怎么在回调中增加参数

慕田峪4524236 2018-12-12 18:19:55
用的 antd 的组件库 写了一个 select,这里的 onChange 只能拿到 valuefunction StatusCombo(props) {     return   <Select onChange={props.onChangeStatus} }>  </Select>}然后写 columns,在 render 中把上边的 StatusCombo 渲染上去, 这里想给 onChangeStatus 再加上 record.key,因为 后面要用createColumns() {    return[{        title: 'status',        dataIndex: 'status',        render: (text, record) => <StatusCombo onChangeStatus={this.onChangeStatus} ></StatusCombo>      }]}最后处理需要 key 和变化的 status,因为 dispath action 时候需要这两个参数onChangeStatus(key, status) {     }我应该怎样才能既获得改变的 status 还能获得当前的 key 呢
查看完整描述

1 回答

?
神不在的星期二

TA贡献1963条经验 获得超6个赞

方法1


<button onClick={(ev, arg1, arg2,……) => {this.handleClick(ev, arg1, arg2,……)}}/> 


handleClick(ev, arg1, arg,……) {

    //code

}

方法2


this.handleclick.bind(this,要传的参数)

// 调用

handleclick(要传的参数,event){

}

方法3


<button onClick={this.handleClick.bind(this, props0, props1, ...}></button>


handleClick(porps0, props1, ..., event) {

    // your code here

}


查看完整回答
反对 回复 2019-01-08
  • 1 回答
  • 0 关注
  • 394 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信