问题描述
我有这个
<Image style={styles.image} source={require('image!logo')}/>
logo.png 添加到 android/app/src/main/res 文件夹的位置.
Where the logo.png is added to android/app/src/main/res folder.
但是图像没有显示出来(我已经重新运行 react-native run-android).
But the image is not getting displayed(I have re-run react-native run-android).
我需要做一些其他的改变吗?
Do i need to do some other changes?
注意使用 http://path/to/image}}/> 有效.
Note that using <Image source={{uri: http://path/to/image}}/> works.
推荐答案
图片文件需要放到res下对应的drawable-xxx文件夹中.
The image file needs to go in the appropriate drawable-xxx folder under res.
尝试将 logo.png
放在 android/app/src/main/res/drawable-hdpi
中,然后重新构建您的应用.
Try putting logo.png
in android/app/src/main/res/drawable-hdpi
and then rebuilding your app.
React Native 站点上有一些信息:https://facebook.github.io/react-native/docs/image.html#adding-static-resources-to-your-android-app
There's some information on the React Native site: https://facebook.github.io/react-native/docs/image.html#adding-static-resources-to-your-android-app
这篇关于React Native Android 本地镜像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!