React Native图片控件的使用
首先定义组件
import {
AppRegistry,
StyleSheet,
Text,
View,
Image,
} from 'react-native';
然后将render返回中的模版增加Image组件视图
class AwesomeProject extends Component {
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to React Native fnwefweccc!
</Text>
<Image style = {styles.pic} source = {{uri: 'https://avatars3.githubusercontent.com/u/6133685?v=3&s=460'}}>
</Image>
</View>
);
}
}
最后在StyleSheet中添加样式即可,
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
backgroundColor: '#F5FCFF',
color:'red',
margin: 10,
},
pic: {
width: 100,
height: 100,
}
});
转载请注明出处!!!!!!!!