有多个按钮可以在ReactJS中调用一个函数

时间:2019-12-11 21:26:21

标签: javascript html node.js reactjs

对不起,标题不清楚。我的问题是我有三个<div class="container"> <div class="myline"> <div class="myblock"> <div class="bin"> <span class="glue"></span> <p class="bingo"> Spiffy hair! </p> <span class="glue"></span> </div> </div> </div> <div class="myline"> <div class="myblock"> <div class="bin"> <span class="glue"></span> <p class="bingo"> Spiffy<sup>&reg;</sup> hair! </p> <span class="glue"></span> </div> </div> </div> <div class="myline"> <div class="myblock"> <div class="bin"> <span class="glue"></span> <p class="bingo"> Vacuum grease </p> <span class="glue"></span> </div> </div> </div> <div class="show-baseline"></div> </div>标签,并且我希望每个标签向button发送一个唯一的参数。但是,无论我按selectSupplier()的哪个按钮,都只会接收最后一个值(“ ultramar”)作为参数。

selectSupplier()

1 个答案:

答案 0 :(得分:1)

您可以这样拨打电话:

this.selectSupplier.bind(this,"Husky");