我的 ImageBackground 模块只显示白色背景。显示的代码基本上是来自 React 在 ImageBackgrounds 上的官方文档的样板模板。我的 uri 不为空。“props.route.params.image”是 react-native-camera 模块中的 TakePictureResponse 类型。
我看了与这个类似的问题,他们的解决方案已经在我的身上实施了。
const styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: 'column',
},
image: {
flex: 1,
resizeMode: 'cover',
justifyContent: 'center',
}
})
render() {
return (
<View style={styles.container}>
<ImageBackground
source={{uri: this.props.route.params.image.uri}}
style={styles.image}
/>
</View>
);
}