如何让下拉按钮在反应引导程序中工作? [英] How to get dropdown-button working in react bootstrap?
问题描述
我正在使用 react-bootstrap
并且正在使用 dropdownbutton
组件.由于某种原因,这不会渲染
.我无法弄清楚.任何帮助将不胜感激.基本不会出现.我还想知道我是否以正确的方式获取 dropdownbutton
的值.顺便说一下,我也导入了href="https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap.min.css"
在索引文件中.
import {Component} from "react";从同构获取"中导入获取;从./AddOnList"导入AddOnList;从react-debounce-input"导入 DebounceInput;从'react-bootstrap' 导入 { DropdownButton };从'react-bootstrap'导入{菜单项};导出默认类 AddOnSearch 扩展组件 {构造函数(道具){超级(道具);this.state = {};}componentDidMount() {fetch('/api/v1/addon').then(响应 => {返回 response.json();}).then(json => {this.setState({allAddOns: json});})}设置类型(类型){this.setState({类型:类型,搜索结果:空}, this.doSearch);}设置查询(查询){this.setState({查询:查询,搜索结果:空}, this.doSearch);}做搜索(){if (this.state.type || this.state.query) {var url = "/api/v1/addon?";如果(this.state.type){url += "type=" + this.state.type;}如果(this.state.query){url += "&q=" + this.state.query;}获取(网址).then(响应 => {返回 response.json();}).then(json => {this.setState({searchResults: json});});}}使成为() {返回 (<div className="row col-md-12 col-sm-12 col-xs-12 pushdown"><div className="col-lg-12"><div className="输入组"><div className="input-group-btn"><DropdownButton className="dropdown-menu" onSelect={event =>this.setType(event.target.eventKey)}><MenuItem eventKey="">所有类型</MenuItem><MenuItem eventKey="OMOD">模块(OMOD)</MenuItem><MenuItem eventKey="OWA">打开网络应用程序 (OWA)</MenuItem></下拉按钮>
<去抖动输入占位符=搜索..."className="表单控件"最小长度={1}去抖动超时={500}onChange={event =>this.setQuery(event.target.value)}/>
{ (this.state.query || this.state.type) ?<AddOnList addons={this.state.searchResults}/>:<AddOnList addons={this.state.allAddOns}/>}