in react-native
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
Image
} from 'react-native';
class Myapp extends Component {
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to React Native~~
</Text>
<Text style={styles.instructions}>
To get started, edit index.android.js
</Text>
<Text style={styles.instructions}>
Shake or press menu button for dev menu
</Text>
<Image
style={styles.picture}
source={require('./img/flowers.png')}
/>
<Text style={styles.end}>
Why image not showing?
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
end:{
fontSize: 20,
textAlign: 'center',
margin:10,
}
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
picture: {
width:50,
height:80,
}
});
AppRegistry.registerComponent('Myapp', () => Myapp);
当我想在链接中显示图像时(使用uri),图像正在显示 但是当我想在本地显示图像时,图像(flowers.png)没有显示.. 我确定flowers.png在img文件夹中。 这段代码的结果是
为什么本地图像没有显示..?