0
我有一個反應原生堆棧導航器屏幕,它將顯示圖像。反應原生導航不能顯示堆棧導航器中的光圖像
如果發現圖像是黑暗的背景(類似於https://tctechcrunch2011.files.wordpress.com/2015/09/react-native.png?w=738),它將顯示得很好,而如果是普通圖像,則不會顯示(https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRf148EuQqC90pqKVJvjraTejon1-A5OKkMuwsnBfxRDlWq1foe)。我不知道如何解決這個問題。如果有任何提示或建議如何讓它工作。我真的很感激。與堆棧Navigator視圖
我的示例代碼如下所示:
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
// Notice these imports:
TextInput,
Image,
Dimensions,
TouchableOpacity
} from 'react-native';
const screenHeight = Dimensions.get('window').height;
const screenWidth = Dimensions.get('window').width;
export default class AboutScreen extends Component {
static navigationOptions = ({navigation}) => ({
title: navigation.state.params.recipe.label,
});
render() {
const { goBack } = this.props.navigation;
const imgUrl = this.props.navigation.state.params.recipe.image;
console.log("imgUrl is >>>", imgUrl);
console.log("this.props.navigation is >>>", this.props.navigation);
return (
<View style={styles.container}>
<View style={styles.picture}>
<Image
style={{width: 200, height: 200}}
source={{uri: imgUrl}}
/>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1
},
picture: {
margin: 10,
height: screenWidth *0.8,
paddingLeft: 10,
backgroundColor: 'white',
shadowColor: "#000000",
shadowOpacity: 0.8,
shadowRadius: 2,
shadowOffset: {
height: 1,
width: 0
}
},
});
嘗試在'Image'道具中添加'resizeMode =「stretch」''。 –
試過,仍然沒有運氣 – WABBIT0111