久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      React 點(diǎn)擊事件的 bind(this) 傳參問(wèn)題

      本文為大家介紹 React 中的點(diǎn)擊事件如何傳參。

      問(wèn)題描述

      先來(lái)看一下問(wèn)題的描述吧。如下圖:

      React 點(diǎn)擊事件的 bind(this) 傳參問(wèn)題

      那么我該怎么解決這個(gè)問(wèn)題呢?

      以下是 HTML 代碼,clickFunction 是點(diǎn)擊事件函數(shù),thisStatus 是要傳遞的參數(shù):

      <div onClick={this.clickFunction.bind(this, thisStatus)>收</div>

      以下是 React 代碼的函數(shù)接收參數(shù)方式,thisStatus 函數(shù)接受的參數(shù):

      clickFunction(thisStatus, event) {      console.log('thisStatus', thisStatus);  }

      來(lái)解決開頭我提出的問(wèn)題,同樣,看圖片吧。

      React 點(diǎn)擊事件的 bind(this) 傳參問(wèn)題

      這樣就可以了。

      總結(jié)

      需要通過(guò) bind 方法來(lái)綁定參數(shù),第一個(gè)參數(shù)指向 this,第二個(gè)參數(shù)開始才是事件函數(shù)接收到的參數(shù):

      <button onClick={this.handleClick.bind(this, props0, props1, ...}></button>     handleClick(porps0, props1, ..., event) {      // your code here  }
      • 事件:this.handleclick.bind(this,要傳的參數(shù))
      • 函數(shù):handleclick(傳過(guò)來(lái)的參數(shù),event)

      原文地址:https://blog.csdn.net/genius_yym/article/details/54135567

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)