【发布时间】:2022-07-20 00:59:37
【问题描述】:
使用带有 uri 类型源的 react-native <Image /> 组件和 blurRadius={8} 间歇性地隐藏整个组件。理想情况下,图像每次都会加载模糊效果。没有迹象表明 onLoad、onError、onLoadEnd 或 onLoadStart 道具存在加载错误,但在 iOS 模拟器的发布版本中,该问题似乎较少发生。这使它看起来像是 Metro bundler 问题,或者可能是渲染问题,如果在使用 blurRadius 时 uri 源加载缓慢,则组件无法渲染图像。
我尝试了一个<ImageBackground /> 组件,源对象中的不同“缓存”选项和记忆,但注意到了相同的结果。我在 StackOverflow 或 react-native github repo 上没有看到关于此的其他问题。
这是我在 FlatList 中渲染的相关组件,该组件存在于相当大的代码库中:
<Image
accessibilityIgnoresInvertColors
blurRadius={8}
source={{ uri: imageUrl }}
style={{
aspectRatio: 15 / 8,
position: 'absolute',
width: '100%',
zIndex: 0
}}
resizeMode="cover"
/>
【问题讨论】: