采纳答案成功!
向帮助你的同学说点啥吧!感谢那些助人为乐的人
新建项目 Image 设置宽高不占位置也不显示,想使用 require 也提示不存在,好像是环境问题,却找不到原因,
不设置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>
<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>
如果是网络图片需要指定图片大小,像这样:<Image source={{uri: 'https://facebook.github.io/react/logo-og.png'}} style={{width: 400, height: 400}} />
给Image设个背景看这个Image组件有没有显示出来,如果显示出了背景可以在Android和iOS上看试一下是不是都显示不出来;
如果还是解决不了问题可以将代码贴出来我帮你看看。
感觉不是代码问题 ,我设置了图片的高宽和背景色 还是不现实,连位置都没有,我贴代码吧
我在问题中添加了一个图片 是代码 和 模拟器的效果
老师 有没有找到是什么问题?
登录后可查看更多问答,登录/注册
一个真实的上线项目,一次完整的开发过程,全面掌握React Native技术
5.0k 12
1.5k 9
1.9k 8
1.8k 7
购课补贴联系客服咨询优惠详情
慕课网APP您的移动学习伙伴
扫描二维码关注慕课网微信公众号