React Native从0到1开发一款App
warning:
这篇文章距离上次修改已过182天,其中的内容可能已经有所变动。
以下是一个简单的React Native应用程序的框架,展示了如何创建一个基本的应用程序:
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
export default class MyApp extends React.Component {
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>Welcome to React Native!</Text>
<Text style={styles.instructions}>To get started, edit App.js</Text>
<Text style={styles.instructions}>{instructions}</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,
},
});
这个例子展示了如何使用React Native的基本组件,如<View>
和<Text>
,以及如何通过StyleSheet.create
定义样式。这是开始构建任何React Native应用程序的基础。在实际开发中,你会添加更多的组件、逻辑和样式来完善应用程序。
评论已关闭