我正在做一个简单的项目.除了<Image source=''/>
之外,几乎所有的功能都能很好地使用它.该图像在android studio和genymotion提供的android emulator中显示良好,但在任何真实设备(moto G3 turbo、nexus 5、galaxy s4等)上都不起作用.我不知道我的代码出了什么问题.这是我的密码
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
Image
} from 'react-native';
class ImageTester 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}>
Double tap R on your keyboard to reload,{'\n'}
Shake or press menu button for dev menu
</Text>
<Image source={require('./img/first_image.png')}></Image>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
AppRegistry.registerComponent('ImageTester', () => ImageTester);
项目 struct :
react 本机版本:react 本机:0.32.1