[英]how to append drop down options inside render function?
below is my code. 下面是我的代码。
console.log
of this.Resources
result is shown below console.log
的this.Resources
结果如下所示
1:"Basavaraj" 2:"Ashuthosh" 3:"Sravan" 4:"Raghavendra" 5:"Prem kumar" 6:"Simran" 7:"Namratha" 8:"Ghanashri" 9:"Ravindra" 10:"Anand" 11:"Shaeen" 1:“ Basavaraj” 2:“ Ashuthosh” 3:“ Sravan” 4:“ Raghavendra” 5:“ Prem kumar” 6:“ Simran” 7:“ Namratha” 8:“ Ghanashri” 9:“ Ravindra” 10:“ Anand ” 11:“谢恩”
render() {
console.log(this.Resources);
const options = this.Resources.map((item, index) =>{
<option key={index} value={item}>{item}</option>
});
return (
<div>
<form>
<div id="select">
<div className="container select">
<div className="row">
<select className="col-4 selectpicker input-large">
<option value="" disabled selected>Select resouce</option>
{options}
</select>
I want all data in this.Resources
should come in select
drop down options. 我想要所有数据。
this.Resources
应该位于select
下拉选项中。
Thanks in advance 提前致谢
You are not returning the html in map.Need to return it. 您没有在map中返回html。需要返回它。
const options = this
.Resources
.map((item, index) => {
return (
<option key={index} value={item}>{item}</option>
);
});
OR 要么
ECMA6 arrow notation with default return: ECMA6箭头符号,默认返回:
const options = this
.Resources
.map((item, index) => (
<option key={index} value={item}>{item}</option>
));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.