React Native学习(三)---完成Hello Worl

2018-06-07  本文已影响12人  偶心依旧来

官方教程

React Native 中文网

阮一峰的ECMAScript 6 入门

将工程中app.js修改为如下保存,用xcode 打开工程跑起来了

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

const instructions = Platform.select({
  ios: 'Hello World iOS',
  android: 'Hello World android',
});

type Props = {};
export default class App extends Component<Props> {
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.instructions}>
          {instructions}
        </Text>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
});
上一篇 下一篇

猜你喜欢

热点阅读