我是本机反应的新手,想显示图像,我用expo设置了项目,并尝试按照以下代码显示图像,但我认为代码是正确的,我不知道为什么它不显示在模拟器中,有人吗?任何想法。
码:
import React from 'react';
import { View, Text, StyleSheet, Image } from 'react-native';
const ImageDetail = (props) => {
return (
<View>
<Image source={require('./beach.jpg')} />
<Text>{props.title}</Text>
</View>
)
};
const style = StyleSheet.create({
});
export default ImageDetail;
我在文件所在的同一文件夹中有图像。
为图像提供具有高度和宽度的样式,否则图像组件将不会显示图像。
<Image style={{height:100,width:100}} source={require('./beach.jpg')} />
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句