是否有本机复选框示例? [英] Is there a react-native checkbox example?

查看:26
本文介绍了是否有本机复选框示例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何简单的示例来实现 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆