React Native - 應用程式



如果您開啟預設應用,可以看出 app.js 檔案 wygląda

import React from 'react';
import { StyleSheet, Text, View } 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>
            <Text>Changes you make will automatically reload.</Text>
            <Text>Shake your phone to open the developer menu.</Text>
         </View>
      );
   }
}

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

輸出

Working on App

你好,世界

要顯示一條簡單的訊息,內容為“歡迎來到 Tutorialspoint”,可移除 CSS 部分,並將要列印的訊息插入由 <<text></text> 標籤包裝在 <<view></view> 內,如下所示。

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

export default class App extends React.Component {
   render() {
      return (
         <View>
            <Text>Welcome to Tutorialspoint</Text>
         </View>
      );
   }
}
Hello World
廣告
© . All rights reserved.