[Wondgirl]从零开始学React Native之image(六)

时间:2021-09-03 05:28:08

[Wondgirl]从零开始学React Native之image(六)

上面的为网络图片,下面的为本地图片,
新建一个images文件夹用来存放本地图片

[Wondgirl]从零开始学React Native之image(六)

index.ios.js

/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/


import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Image,
View
} from 'react-native';

export default class demo extends Component {
render() {
return (
<View>

<Image source={{uri: 'https://facebook.github.io/react/img/logo_og.png'}} style={{width: 400, height: 400}} />



<Image style={styles.image} source={require('./images/icon.png')} />


</View>
);
}
}

//样式
const styles = StyleSheet.create({
image:{

width:200,
height:200,
borderWidth:1,
marginLeft:50,



}

});

AppRegistry.registerComponent('demo', () => demo);