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
广告