admin管理员组文章数量:1328747
I'm working with react-bootstrap and ReactJS. I was expecting the select to take the options as an argument, but not seeing a way to populate the options. This is the code I have thus far. How do I pass in the data
render() {
return (
<div>
<Button bsStyle="primary" onClick={this.open}>Add Parameter</Button>
<Modal show={this.state.showModal} onHide={this.close}>
<Modal.Header>
<Modal.Title>Add / Edit Parameter</Modal.Title>
</Modal.Header>
<Modal.Body>
<form>
<FormGroup controlId="parameterType">
<ControlLabel>Type</ControlLabel>
<FormControl ponentClass="select" placeholder="Type">
<option value="select">select</option>
<option value="other">...</option>
</FormControl>
</FormGroup>
</form>
</Modal.Body>
<Modal.Footer>
<Button bsStyle="primary" onClick={this.close}>Save Changes</Button>
</Modal.Footer>
</Modal>
</div>
)
}
I'm working with react-bootstrap and ReactJS. I was expecting the select to take the options as an argument, but not seeing a way to populate the options. This is the code I have thus far. How do I pass in the data
render() {
return (
<div>
<Button bsStyle="primary" onClick={this.open}>Add Parameter</Button>
<Modal show={this.state.showModal} onHide={this.close}>
<Modal.Header>
<Modal.Title>Add / Edit Parameter</Modal.Title>
</Modal.Header>
<Modal.Body>
<form>
<FormGroup controlId="parameterType">
<ControlLabel>Type</ControlLabel>
<FormControl ponentClass="select" placeholder="Type">
<option value="select">select</option>
<option value="other">...</option>
</FormControl>
</FormGroup>
</form>
</Modal.Body>
<Modal.Footer>
<Button bsStyle="primary" onClick={this.close}>Save Changes</Button>
</Modal.Footer>
</Modal>
</div>
)
}
Share
Improve this question
asked Feb 20, 2017 at 1:16
jkratz55jkratz55
8814 gold badges14 silver badges30 bronze badges
1 Answer
Reset to default 6you'd map over your data to produce the options programmatically. Suppose your options are in an array:
options=[{value: 'select'}, {value: 'other'}]
<FormControl ponentClass="select" placeholder="Type">
{
options.map((option, index) => {
return (<option key={index} value={option.value}>{option.value}</option>)
})
}
</FormControl>
本文标签: javascriptreactbootstrap Add Options to SelectReactJSStack Overflow
版权声明:本文标题:javascript - react-bootstrap Add Options to Select - ReactJS - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742260470a2442417.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论