请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

Image 无法使用问题

新建项目 Image 设置宽高不占位置也不显示,想使用 require 也提示不存在,好像是环境问题,却找不到原因,https://img1.sycdn.imooc.com//szimg/5b2b05c20001d43413960462.jpg

正在回答 回答被采纳积分+3

3回答

CrazyCodeBoy 2018-06-21 14:22:29

不设置Image的source,Image是不显示的,参考代码:

<View style={{flex:1}}>
    <Image style={{ width: 100, height: 100,backgroundColor: "#000"}} source={{uri: 'https://facebook.github.io/react/logo-og.png'}}/>
    <Image style={{ width: 100, height: 100,backgroundColor: "#d15"}} source={{uri: 'https://facebook.github.io/react/logo-og.png'}}/>
    <Text style={styles.text}> this HomePage</Text>
    <Text style={styles.text}> this HomePage</Text>
    <Text style={styles.text}> this HomePage</Text>
    <Text style={styles.text}> this HomePage</Text>
</View>


0 回复 有任何疑惑可以回复我~
提问者 qq_小小白_5 2018-06-21 11:03:45

<View style={BaseStyles.container_column}>
   <Image style={{ width: 100, height: 100,backgroundColor: "#000"}} />
   <Image style={{ width: 100, height: 100,backgroundColor: "#d15"}} />
   <Text style={styles.text}> this HomePage</Text>
   <Text style={styles.text}> this HomePage</Text>
   <Text style={styles.text}> this HomePage</Text>
   <Text style={styles.text}> this HomePage</Text>
</View>

0 回复 有任何疑惑可以回复我~
CrazyCodeBoy 2018-06-21 09:49:40
  1. 如果是网络图片需要指定图片大小,像这样:<Image source={{uri: 'https://facebook.github.io/react/logo-og.png'}}       style={{width: 400, height: 400}} />

  2. 给Image设个背景看这个Image组件有没有显示出来,如果显示出了背景可以在Android和iOS上看试一下是不是都显示不出来;

  3. 如果还是解决不了问题可以将代码贴出来我帮你看看。

0 回复 有任何疑惑可以回复我~
  • 提问者 qq_小小白_5 #1
    感觉不是代码问题 ,我设置了图片的高宽和背景色 还是不现实,连位置都没有,我贴代码吧
    回复 有任何疑惑可以回复我~ 2018-06-21 09:54:04
  • 提问者 qq_小小白_5 #2
    我在问题中添加了一个图片 是代码 和 模拟器的效果
    回复 有任何疑惑可以回复我~ 2018-06-21 09:59:51
  • 提问者 qq_小小白_5 #3
    老师 有没有找到是什么问题?
    回复 有任何疑惑可以回复我~ 2018-06-21 11:04:36
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号