是否有本机复选框示例? [英] Is there a react-native checkbox example?
问题描述
是否有任何简单的示例来实现 react-native CheckBox?Facebook 没有提供任何示例.我所指的 CheckBox 组件可以在此处的文档中找到:
以上代码在 iOS 设备上的显示方式:
Are there any simple examples of implementing a react-native CheckBox? Facebook does not provided any examples. The CheckBox component that I am referring to can be found in the documentation here: http://facebook.github.io/react-native/docs/checkbox.html
Currently, the CheckBox component is only supported on Android as it is stated here. You should use the Switch component for iOS.
For Android, usage is pretty straight forward:
<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>
View and Text components are optional, just to show how CheckBox can be used along with those. Code above will produce this screen on Android device:
This is how the above code appears on an iOS device:
这篇关于是否有本机复选框示例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!