addResults选项在bootstrap-select中不起作用

时间:2018-05-16 13:27:39

标签: javascript reactjs bootstrap-select

我想在bootstrap-select中使用addResults选项添加新项目。我应该被提示添加搜索字符串,但我收到默认消息No Results

jsfiddle

component.jsx

class TodoApp extends React.Component {
  constructor(props) {
    super(props);
  }

  componentDidMount() {
    $(this.selectPicker).selectpicker({
      liveSearch: true,
      addResults: true,
    });
  }

  render() {
    return (
      <div>
        <select className="form-control" data-width="100%" ref={el => (this.selectPicker = el)}>
                    <optgroup label="Group 1">
                      <option defaultValue>Team</option>
                      <option value="1">AAA</option>
                    </optgroup>
                    <optgroup label="Group 2">
                      <option value="2">BAC</option>
                      <option value="3">BAY</option>
                    </optgroup>
                    <optgroup label="Group 3">
                      <option value="4">DACA</option>
                    </optgroup>
                  </select>
      </div>
    )
  }
}

ReactDOM.render(<TodoApp />, document.querySelector("#app"))

0 个答案:

没有答案