我有我的选择列表中的组件渲染我的选择列表:使用react js获取选定的选项文本?
<form className="pure-form">
<select ref="selectMark" className="mark-selector"
onChange={this.onChange}>{this.getOptions()}
</select>
</form>
我有组件上的方法来创建选项:
getOptions: function() {
return this.props.renderProps.data.map(function (item) {
return <option key={item.value} value={item.value}>{item.label}</option>;
}.bind(this));
},
我的onChange方法工作正常的值:
onChange: function(event) {
var newValue = event.nativeEvent.target.value;
this.props.renderProps.onSaveCare(newValue);
this.setState({value: newValue});
this.toggleEdit();
},
有没有办法让我选择文字?这给了我不确定
event.nativeEvent.target.text; //undefined
对IE不起作用。我用IE 11测试过。 – ChillyPenguin