Learn the Basics

使用Image

1. 引用

import { Image } from 'react-native';

2. 使用

    format:

    <Image source={{}} style{{}} />

例如:

<Image source={{uri: 'https://upload.wikimedia.org/wikipedia/commons/d/de/Bananavarieties.jpg'}}
            style={{ 193, height: 110}}/>

源代码:

App.js

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

export default class App extends React.Component {
  render() {
    return (
      <View style={styles.container}>
        <Text>Open up App.js to start working on your app!</Text>
        <Image source={{uri: 'https://upload.wikimedia.org/wikipedia/commons/d/de/Bananavarieties.jpg'}}
            style={{ 193, height: 110}}/>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

Reference:

1. Learn the Basics - v0.59

原文地址:https://www.cnblogs.com/xiaobin-hlj80/p/10571070.html