有没有实现react native复选框的简单示例?Facebook没有提供任何例子.我提到的复选框组件可以在这里的文档中找到:http://facebook.github.io/react-native/docs/checkbox.html
有没有实现react native复选框的简单示例?Facebook没有提供任何例子.我提到的复选框组件可以在这里的文档中找到:http://facebook.github.io/react-native/docs/checkbox.html
目前,复选框组件仅在Android上受支持,如here所述.您应该使用iOS的交换机组件.
对于Android来说,使用非常简单:
<View style={{ flexDirection: 'column'}}>
<CheckBox />
<View style={{ flexDirection: 'row' }}>
<CheckBox
value={this.state.checked}
onValueChange={() => this.setState({ checked: !this.state.checked })}
/>
<Text style={{marginTop: 5}}> this is checkbox</Text>
</View>
</View>
视图和文本组件是可选的,只是为了显示复选框如何与这些组件一起使用.
以上代码在iOS设备上的显示方式如下: