我相信这可能与我存储图像的位置有关。它们可以在 ../ProjectName/img/fileName.png
中找到
我需要做些什么来加载文件以便可以访问它们吗?
<View style={styles.container}>
<HomeHeaderTitle isHomePage={true}/>
<View style={styles.quoteContainer}>
<Image source={require('../../img/backgroundQuote3.png')} />
</View>
</View>
当我将上面的代码添加到我的代码中时,它给了我这个错误:
react-native-cli: 2.0.1
react-native: 0.39.0
最佳答案
我看到了你的问题。您应该在一个级别上阅读源图像吗?
例如:
<Image source={require('../img/backgroundQuote3.png')} />
另外,当你想使用背景图片时,是否应该使用element is parent view?
例如:
<Image source={require('../img/backgroundQuote3.png')}>
<View>
</View>
</Image>
加油!
PS:别忘了投票!
关于ios - 使用 React Native,尝试使用背景图片时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41621562/