react-native - 有一个占位符用于 react 原生选择器

标签 react-native

有没有办法在用户点击它之前显示 react 原生选择器的占位符。这个想法是有一个选择器,上面写着“国籍”,一旦你点击并选择你的国家,它就会呈现国家。我想在没有“国籍”作为选择器中的可用选项的情况下执行此操作。

最佳答案

您可以改用 native-base 的选择器。

1. 运行:

npm i native-base --save

2. 导入为:
import {Picker} from 'native-base';

3. 用作:
<Picker
placeholder="Start Year" // yipeee, placeholder
iosIcon={<Ionicons name="ios-arrow-down" />} // right icon
selectedValue={this.state.selected_id} // your selected item value
style={{
    // your styles
}}
// onValueChange={this.onValueChange.bind(this)} // use it the way it suites you
onValueChange={(v)=>this.setState({selected_id:v})} // use it the way it suites you
>


 <Picker.Item label="Val 1" value="1" />
   <Picker.Item label="Val 2" value="2" />
   <Picker.Item label="Val 3" value="3" />

</Picker>

关于react-native - 有一个占位符用于 react 原生选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37440464/

相关文章:

react-native - React Native 父级如何将函数传递给子级

ios - 在 FBSDKCoreKit 中的“SKProd”类型的对象上找不到属性 'subscriptionPeriod'

android - react native android 中 GIF 图像的圆角问题

javascript - 当用户从 React Native 中的另一个页面导航回页面时,如何重新加载页面?

android - Android 上 React Native 应用程序周围的粗黑边/边框

react-native - iOS 模拟器内的 Expo React Native 应用程序不断使用 socket.io 重新连接

react-native - 即使在应用程序关闭后如何使 socket-io 工作

react-native - onLoadEnd 未在 native react 中触发

react 原生的 Firebase 身份验证错误?

reactjs - 如何在 React Native for Production 中添加源映射?