React Native - App
如果您打开默认应用程序,您可以观察到 app.js 文件如下所示
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', }, });
输出
Hello world
要显示一条简单消息"欢迎来到 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> ); } }