【问题标题】:React native flat list don't show data screen after generating a release ApK生成发布ApK后反应原生平面列表不显示数据屏幕
【发布时间】:2019-10-23 12:29:28
【问题描述】:

我正在使用 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}

        />

【问题讨论】:

  • 你能在 UI 中 console.log 或打印 this.props.data 吗?

标签: reactjs react-native react-redux react-native-flatlist


【解决方案1】:

这是我的工作 https://stackoverflow.com/a/56801525/7483108

在我的例子中,我使用非安全(http 而不是 https)调用 api。所以 api 适用于调试环境,但不适用于发布。你可以添加这一行

android:usesCleartextTraffic="true"
to AndroidManifest.xml

这样

<uses-permission android:name="android.permission.INTERNET" />

<application
      ...
      android:usesCleartextTraffic="true"
      ... 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-05-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-08
    • 1970-01-01
    • 1970-01-01
    • 2020-07-08
    相关资源
    最近更新 更多