[英]React Native using picker to select country & flag
I would like to know how to implement React Native picker to select a country and an image of the flag. 我想知道如何实现React Native选择器来选择国家和国旗的图像。 Any help would be appreciated
任何帮助,将不胜感激
import React, { Component } from 'react'
import { Text, View, Image, Picker } from 'react-native'
export default class country extends Component {
constructor(props) {
super(props);
this.state = { country: ""};
this.state = {updatedCountry};
}
render() {
return (
<View>
<Picker selectedValue = {this.state.country} onValueChange = {this.updatedCountry}>
<Picker.Item label = "America" value = "flag" />
<Picker.Item label = "England" value = "Flag" />
</Picker>
<Text style = {styles.text}>{this.state.country}</Text>
</View>
)
}
}
I just came across this react-native library react-native-country-picker-modal while looking for the same. 我只是遇到了这个本机库本身的react-native-country-picker-modal,同时寻找相同的东西。
Supports both Android and iOS 支持Android和iOS
Uses world-countries to populate the list. 使用世界国家填充列表。
If you are very keen you can check out the internals of the implementation src/CountryPicker.js , scripts/transform-world-countries.js , src/countryFlags.js 如果您非常热衷,可以查看实现src / CountryPicker.js , scripts / transform-world-countries.js , src / countryFlags.js的内部结构。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.