1

我只是第一次开发一个 react-native 应用程序。我正在使用导航,并且必须使用 react-nativereact-native-router-flux创建一个显示提要Image和组件的提要页面。问题是,应用程序从远程服务器获取一些数据的速度非常慢,即使使用本地主机也是如此。TextFlatList

数据格式如下

{
    [
        title : "Test title",
        description : "Test Description",
        imageUrl : 'http://192.168.22.22:8887/image.png'
    ],
    [
        title : "Test title 2",
        description : "Test Description 2",
        imageUrl : 'http://192.168.22.22:8887/image2.png'
    ]
}

我试图从浏览器访问 api url,它也做得很快。但是当我通过我的 react-native 应用程序访问时,它太慢了。像 7 秒等待页面完成加载获取数据。我认为问题出在我使用来自远程数据的图像时。我是这样做的

<Image
    style={{width: 50, height: 50}}
    source={{uri: HOST_URL + '/' + rowData.imageUrl }}
/>

这可以提高速度吗?使用加载遥控器Image会影响速度吗?或者我必须使用延迟图像加载概念加载图像?

4

1 回答 1

0

如果您没有太多图像,您可以将它们保存在您的项目中并requie("// the address of image in your project")在源代码中使用

于 2018-08-20T05:50:09.393 回答