React Native
来源:互联网 发布:易语言蜘蛛池源码 编辑:程序博客网 时间:2024/05/16 09:10
本文CSDN地址
本文有道地址
下一篇 React Native - Props属性和State状态
ReactNative 基础开发
- 基础前端开发知识
- Node.js基础
- JSX语法基础
- Flexbox布局
了解文件结构
App.js
React Native 下面例举了一些已经具备的内置组件:
import { Platform, StyleSheet, Text, View, TabBarIOS} from 'react-native';
通过 improt
引入该组件,比如我们页面上需要显示文本,我们则使用 <Text>Hello world!</Text>
。
常量对象的定义和扩展
const instructions = Platform.select({ ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu', android: 'Double tap R on your keyboard to reload,\n' + 'Shake or press menu button for dev menu',});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, },});
定义App.js类的组件
import React, { Component } from 'react'; //1.export default class App extends Component<{}> { //2. render() { return ( <View style={styles.container}> <Text style={styles.welcome}> Welcome to React Native! </Text> <Text style={styles.instructions}> 123{this.props.text}123 </Text> <Text style={styles.instructions}> {instructions} </Text> </View> ); }
Component
模块则是用来告知当前类具备封装成一个组件的能力。- 组件的封装及页面的定制。
render
方法中返回一些用于渲染结构的 JSX 语句。extends
扩展
index.js
import { AppRegistry } from 'react-native';//1import App from './App';//3AppRegistry.registerComponent('XXXXX', () => App);//2
AppRegistry
模块则是用来告知 React Native 哪一个组件被注册为整个应用的根容器。- 你无需在此深究,因为一般在整个应用里 `AppRegistry.registerComponent 这个方法只会调用一次。
- 导入名为App的组件,也就上述提到的App.js。
阅读全文
0 0
- react native
- React Native
- React Native
- React- Native
- react-native
- React Native
- React Native
- react native
- React Native
- react-native
- React Native
- react native
- React Native
- React Native
- React Native
- React Native
- react native
- React Native
- raspberry pi bluetooth 连接android手机
- 锐捷RG-BDS,态势感知技术助力网络安全前行
- google 相册数据迁移至另一google账号方法
- [ 杂题 ] BZOJ5085
- 动态内存与智能指针
- React Native
- leveldb源码分析
- Excel
- MySQL可以存放的数据类型
- EFilm 4.1安装文件 keygen 注册机
- pioneer rosaria 话题读取声呐数据和声呐避障
- 物联网技术下的医疗,你的安全我用心守护
- 产品经理内功修炼——扁平化交互设计技巧
- A17_多线程