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

用的 antd 的组件库 

写了一个 select,这里的 onChange 只能拿到 value


function 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 呢


慕田峪4524236
浏览 395回答 1
1回答

神不在的星期二

方法1<button onClick={(ev, arg1, arg2,……) => {this.handleClick(ev, arg1, arg2,……)}}/>&nbsp;handleClick(ev, arg1, arg,……) {&nbsp; &nbsp; //code}方法2this.handleclick.bind(this,要传的参数)// 调用handleclick(要传的参数,event){}方法3<button onClick={this.handleClick.bind(this, props0, props1, ...}></button>handleClick(porps0, props1, ..., event) {&nbsp; &nbsp; // your code here}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript