反应原生图像加载太慢

时间:2021-01-14 22:16:34

标签: image react-native base64

我从 react-native-image-filter 得到了 22 张图片。 此图像是 base64 格式, 这是渲染运行的代码。

render() {
        const { images, imageIndex } = this.state;
        return (
          <View style={styles.container}>
            {images?.length > 21 && <View style={{ flex: 1 }}>
              <Image resizeMode={'contain'} source={{ uri: `data:image/png;base64,${images[imageIndex]?.base64}` }} style={{ width: 400, flex: 1 }} />
            </View>}
            <View style={{ height: 140, paddingVertical: 20 }}>
              <ScrollView horizontal>
                {images?.map((item, index) => {
                  return (
                    <View style={[{ marginHorizontal: 10 }, styles.center]}>
                      <Image
                        resizeMode={'cover'}
                        key={index.toString()}
                        onPress={() => this.setState({ imageIndex: index })}
                        source={{ uri: `data:image/png;base64,${item.base64}` }}
                        style={{ width: 80, height: 100, borderRadius: 8 }} />
                    </View>
                  )
                })}
              </ScrollView>
            </View>
          </View>
        );
      }

一切都很好,但是图片加载太慢了。 我怎样才能创建加载速度?帮帮我...

0 个答案:

没有答案