繁体   English   中英

无法选择其他选项 <select> ,但是选项列表在下拉列表中可见…

[英]Unable to choose other options in <select>, however the list of options are visible on dropdown…

在这里,我正在向服务器发出表单值,目前可以正常工作。但是,除了默认选项外,我无法从选择输入中选择其他值...请帮助!

 var Query = React.createClass({
  getInitialState(){
    return{
      value:'Sunday'
    }
  },

  change(e){
    this.setState({value: e.target.value});
  },

  join() {
    var memberName = React.findDOMNode(this.refs.name).value;
    var dayz = React.findDOMNode(this.refs.day).value;
    //emits name and day to the server....
    this.props.emit('join',{ name: memberName, day: dayz });
  },

  render(){
    return(
      <div>
        <form action="javascript:void(0)" onSubmit={this.join}>
          <input ref="name" type="text" required/>
          //unable to select other options apart the first (sunday => Wow)
          <select ref="day" onChange={this.Change} value={this.state.value}>
            <option  value="sunday">Wow</option>
            <option  value="a">ssd</option>
            <option  value="Java">Java</option>
            <option  value="C++">C++</option>
          </select>
          <button>Join</button>
        </form>
      </div>
    );
  }
});
module.exports = Query;

<select>有一个错字:它的大写字母“ C”而不是小写的“ c”(如函数名称一样)。 更新this.Changethis.change

<select ref="day" onChange={this.change} value={this.state.value}>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM