我正在尝试使用 react-native-picker-select 包。根据他们的文档,@react-native-picker/picker 是一个依赖项。但是..
将此包添加到我的 RN 应用程序后,它构建时没有错误,但应用程序崩溃了。
在他们的 repo 协议(protocol)中寻找问题,但我不认为有修复的资源。已经在他们的 repo 中创建了一个问题。
最佳答案
添加 <Text></Text>
<Picker></Picker>
之后的组件组件,在父级内部 <View></View>
<Picker></Picker>
的组成部分组件,就像下面的代码片段一样:
<View style={{flex: 1, borderWidth: 1, borderColor: '#0f0'}}>
<Picker
style={{...styles.itemPicker, color: theme.TEXT}}
mode="dropdown"
selectedValue={unit_elevation}
onValueChange={(value) => this.changeUserPreferences('unit_elevation', value)}
>
<Picker.Item label={messages.meters} value="M" />
<Picker.Item label={messages.feet} value="FT" />
</Picker>
<Text style={{width: '100%', height: 60, position: 'absolute', bottom: 0, left: 0}}>{' '}</Text>
</View>
关于react-native - @react-native-picker/picker 导致我的应用程序崩溃 (android),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66670721/