React-Native 开发实用指南
warning:
这篇文章距离上次修改已过193天,其中的内容可能已经有所变动。
import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
const ExampleComponent = () => {
return (
<View style={styles.container}>
<Text style={styles.text}>Hello, React Native!</Text>
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
text: {
fontSize: 20,
color: '#000',
},
});
export default ExampleComponent;
这段代码展示了如何在React Native中创建一个简单的组件,该组件渲染了一个文本元素。它使用了StyleSheet
来定义文本和容器视图的样式,这是React Native中处理样式的标准方式。通过这个例子,开发者可以学习到如何组织React Native应用的结构,以及如何使用React Native的基本组件。
评论已关闭