用react的for循环怎么实现重复输入RadioButton
1个回答
展开全部
比较简单的,在render函数里面定义一个array,然后for里面生成的东西依次push进去,最后显示
render() {
let shows = []
for (let i = 0; i < this.props.appointExpertPostFormReduce.num; i++){ shows.push(<RadioButton value={/*具体value*/} key={i}>{/*具体显示*/}</RadioButton>)
}
return ( <div style={{display:"inline"}}>
//前面省略,贴代码最好省略无关的内容 <Form horizontal>
<div id="box">
<FormItem {...formItemLayout} label="选择专家">
<RadioGroup defaultValue="a" size="large">
<RadioButton value="a">赵六</RadioButton>
<RadioButton value="b">李四</RadioButton>
<RadioButton value="c">王五</RadioButton>
<RadioButton value="d">张三</RadioButton>
{shows} </RadioGroup>
</FormItem>
</div>
);
},
});
render() {
let shows = []
for (let i = 0; i < this.props.appointExpertPostFormReduce.num; i++){ shows.push(<RadioButton value={/*具体value*/} key={i}>{/*具体显示*/}</RadioButton>)
}
return ( <div style={{display:"inline"}}>
//前面省略,贴代码最好省略无关的内容 <Form horizontal>
<div id="box">
<FormItem {...formItemLayout} label="选择专家">
<RadioGroup defaultValue="a" size="large">
<RadioButton value="a">赵六</RadioButton>
<RadioButton value="b">李四</RadioButton>
<RadioButton value="c">王五</RadioButton>
<RadioButton value="d">张三</RadioButton>
{shows} </RadioGroup>
</FormItem>
</div>
);
},
});
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询