我正在使用react-native,开发过程中一切正常,但是,当我构建APK(使用本教程:https://facebook.github.io/react-native/docs/signed-apk-android.html#content)并将其安装在我的设备上时,平面列表不显示任何数据一切正常,登录屏幕连接到已登录的api因此api运作良好那么为什么平板列表不显示任何数据。有人遇到过同样的问题吗?
componentDidMount() {
this.props.getCoffeeCategory()
}
//flatlist code
<FlatList
style={{ flex: 1 }}
showsHorizontalScrollIndicator={false}
horizontal={true}
data={this.props.data}
renderItem={this._renderListItem}
keyExtractor={item => item.id}
/>
这是我的工作https://stackoverflow.com/a/56801525/7483108
在我的情况下,我使用不安全的api(http而不是https)调用api。因此,api在调试环境中效果很好,但在发布环境中却不起作用。您可以添加此行
android:usesCleartextTraffic="true"
to AndroidManifest.xml
那样
<uses-permission android:name="android.permission.INTERNET" />
<application
...
android:usesCleartextTraffic="true"
...