react - 6. 显示图片

访问量: 274

参考:https://facebook.github.io/react-native/docs/props

新建一个页面:screens/ShowImage.js

import React,  { Component} from 'react';
import {Platform, StyleSheet, Text, View, Button} from 'react-native'

export default class ShowImage extends React.Component{

  render(){
    return (
      let pic = {
        uri: "http://siweitech.b0.upaiyun.com//image/1104/fruit_apple.jpg"
      }
      return (
        <View>
          <Image source={pic} style={{width: 300, height: 400}}/>
        </View>
      )

    )
  }

}

增加路由:(App.js)

import ShowImage from 'screens/ShowImage'

const myNavigator = createStackNavigator(
  {
    Home: Home,
    ShowImage: ShowImage
  },
  {
    initialRouteName: "Home"
  }
)

export default createAppContainer(myNavigator)

增加入口:(screens/Home.js)

订阅/RSS Feed

Subscribe

分类/category