【发布时间】:2017-02-05 00:15:02
【问题描述】:
我有以下输入字段,我需要获取输入的输入并将其传递给下面显示的按钮的 onClick 事件。
<input type="text" style={textFieldStyle} name="topicBox" placeholder="Enter topic here..."/>
<input type="text" style = {textFieldStyle} name="payloadBox" placeholder="Enter payload here..."/>
<button value="Send" style={ buttonStyle } onClick={this.publish.bind(this,<value of input field 1>,<value of input field2>)}>Publish</button><span/>
我有一个名为 publish 的方法,它接受两个字符串参数。代替这些字符串,我需要传递在输入字段中输入的值。如果不将值存储在状态中,如何实现这一点?我不想将输入字段值存储在状态变量中。任何帮助将不胜感激。
【问题讨论】:
标签: javascript button reactjs input typescript