【发布时间】:2019-01-30 07:46:11
【问题描述】:
如何在 react native <CheckBox></CheckBox> 中制作多个复选框?
目前我的复选框是这样的:
if(this.state.specialise_list != null){
return this.state.specialise_list.map((data, i)=>(
<View key={i} style={{ flexDirection: 'row' }}>
<CheckBox
containerStyle={{ borderColor: 'transparent' }}
value={this.state.specialise}
onValueChange={(itemValue, itemKey) => this.setState({ specialise: itemValue })} />
<Text style={{marginTop: 5}}> { data.name }</Text>
</View>
))
}
我上面的代码将检查所有的复选框。我正在尝试以selected_specialise: [ '1', '2', '5', '24' ]; 的形式将选中的复选框插入到数组中,如果未选中特定的复选框,数据将从数组中删除。
【问题讨论】:
标签: arrays react-native checkbox