簡體   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