React Native Picker (多列数据)
来源:互联网 发布:长春淘宝图片拍摄 编辑:程序博客网 时间:2024/06/05 18:50
** Sample React Native App * https://github.com/facebook/react-native * @flow */"use strict"import React, {Component} from 'react'import { AppRegistry, View, Text, Picker, StyleSheet} from 'react-native'var FirstData = [ '1', '2', '3', '4', '5', '6']var SecondData = [ '11', '22', '33', '44', '55', '66']var ThirdData = [ '111', '222', '333', '444', '555', '666']// 读取本地json文件(城市选择器,后续更新)let jsonData = require('./area.json')class HelloWorld extends Component { constructor(props) { super(props) this.state={ firstValue: FirstData[0], secondValue: SecondData[0], thirdValue: ThirdData[0], } } updateFirstValue(language) { this.setState({ firstValue: language, }) } updateSecondValue(language) { this.setState({ secondValue: language, }) } updateThirdValue(language) { this.setState({ thirdValue: language, }) } renderPicker(key, i) { console.log(key, i) return <Picker.Item key={i} label={key} value={key} /> } render() { return ( <View style={styles.container}> <Text style={styles.text}>{this.state.firstValue+this.state.secondValue+this.state.thirdValue}</Text> <View style={styles.pickerViewContainer}> <Picker style={styles.pickerStyle} selectedValue={this.state.firstValue} onValueChange={(language) => this.updateFirstValue(language)}> {FirstData.map((key, i) => this.renderPicker(key, i))} </Picker> <Picker style={styles.pickerStyle} selectedValue={this.state.secondValue} onValueChange={(language) => this.updateSecondValue(language)}> {SecondData.map((key, i) => this.renderPicker(key, i))} </Picker> <Picker style={styles.pickerStyle} selectedValue={this.state.thirdValue} onValueChange={(language) => this.updateThirdValue(language)}> {ThirdData.map((key, i) => this.renderPicker(key, i))} </Picker> </View> </View> ); }}const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', flexDirection: 'column', backgroundColor: '#F5FCFF' }, text: { width: 200, height: 60, marginTop: 100, backgroundColor: 'white', justifyContent:'center', alignItems: 'center', borderRadius: 5, }, pickerViewContainer: { flex: 1, flexDirection: 'row', paddingTop: 30 }, pickerStyle: { flex: 1, }})AppRegistry.registerComponent('HelloWorld', () => HelloWorld);****************************** 知识点 ******************************
1.实现多列:把 3 个picker放在同一个View上;2.排列方式为: row ;3.flex设置为: 1(各占三分之一并充满父组件);
****************************** 效果图 ******************************
阅读全文
0 0
- React Native Picker (多列数据)
- react-native-image-picker
- react-native-image-picker
- react-native-image-picker
- react-native- images -crop-picker
- react native Picker 使用详解
- react-native-image-picker配置
- React-native 之Picker的使用
- 《React-Native系列》41、刨根问底Picker组件
- 《React-Native系列》40、刨根问底Picker组件
- React Native之Picker组件详解
- react-native-country-picker-modal手机通讯录
- React Native Switch和Picker的认识
- react-native的下拉列表Picker
- react-native-image-crop-picker学习
- react-native-image-crop-picker记录学习
- react-native中Picker动态设置数据源
- React Native开源库react-native-image-crop-picker使用图解
- 操作系统 --- 中断和轮询
- 钢铁行业,煤炭行业,有色金属行业的历史利润,负债率
- 函数调用规范__cdecl和__stdcall的区别
- Android使用jsoup解析音乐网站获取歌名与歌手名显示在ListView上
- SlidingMenu侧拉菜单,两侧都可以拉动
- React Native Picker (多列数据)
- BZOJ2242 SDOI2011 计算器
- Docker指定网桥和指定网桥IP
- P2327 [SCOI2005]扫雷
- PHP开源框架之AJAX
- Ubuntu14.04.3安装Openssh-server
- 条件随机场专题(3)--说起CRF,不得不提的HMM
- win10下安装caffe新得
- 搭建自己的docker registry,非生产环境