当项目建立好后找到app.js

复制代码

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

const instructions = Platform.select({
  ios: 'Press Cmd+R to reload,\n' +
    'Cmd+D or shake for dev menu',
  android: 'Double tap R on your keyboard to reload,\n' +
    'Shake or press menu button for dev menu',
});

type Props = {};
export default class App extends Component<Props> {
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>
          Hello world react native!
        </Text>
        
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
});
 

然后命令行运行

G:\secondproject>react-native bundle --platform android --dev false --entry-file
 index.js \ --bundle-output android/app/src/main/assets/index.android.bundle \ -
-assets-dest android/app/src/main/res/

然后编译

G:\secondproject>react-native run-android

reactnative入门Hello world

作者:蒋光洵 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-21
  • 2021-05-15
  • 2021-04-02
  • 2021-10-15
  • 2021-06-05
猜你喜欢
  • 2021-05-10
  • 2021-08-02
  • 2021-07-19
  • 2021-07-16
  • 2022-01-30
  • 2021-10-26
相关资源
相似解决方案