react-native-city-select
Table of contents
Install
npm install react-native-city-select@latest --save
Usage
;; { superprops thisstate = isVisable: false cityText: '' cityId: '' } { this } { this } { return <View style=stylescontainer> <TouchableOpacity onPress=thishandleChangeCityStatus > <Text> click me! </Text> </TouchableOpacity> <Text> thisstatecityTextthisstatecityId </Text> <CitySelect isVisable=thisstateisVisable cancelCity=thishandleChangeCityStatus selectCity=thishandleCitySelect cityData=CITY selectedId=thisstatecityId cityGrid=2 /> </View> } const styles = StyleSheet;
Notice
Position: Put the CitySelect component at the bottom of the container, to avoid hierarchical relation problem.
City data: Get the data of Chinese cities, click here
const CITY = A: cityId: '279' cityName: '阿坝' cityNameEn: 'Aba' cityId: '329' cityName: '安康' cityNameEn: 'Ankang' ... ...
Options
Key | Type | Defalut |
---|---|---|
cancelCity | function | null |
cancelColor | string | '#51a8fb' |
cancelSize | number | 14 |
selectedBg | string | '#26A1FD' |
selectedId | string | '' |
selectCity | function | null |
cityData | object | null |
cancelText | string | '取消' |
titleText | string | '选择城市' |
hasHeader | boolean | true |
cityGrid | number | 1 |
The Response Object
key | Type |
---|---|
cityObj | Object |