Q 函数式组件
import React from 'react';
import { Text, View } from 'react-native';
const HelloWorldApp = () => {
return (
<View style={{
flex: 1,
justifyContent: 'center',
alignItems: 'center'
}}>
<Text>Hello, world!</Text>
</View>
);
}
export default HelloWorldApp;
Q Class 组件
import React, { Component } from 'react';
import { Text, View } from 'react-native';
class HelloWorldApp extends Component {
render() {
return (
<View style={{
flex: 1,
justifyContent: "center",
alignItems: "center"
}}>
<Text>Hello, world!</Text>
</View>
);
}
}
export default HelloWorldApp;
Q JSX
- {}
Q Props
- 定制组件渲染的参数
Q State
- 组件的私人数据记录
- Redux
Q 处理触摸事件
<Button\ onPress={() => {\ Alert.alert('你点击了按钮!');\ }}\ title="点我!"\ />
Q Touchable 系列组件
Q ScrollView
- flex: 1
Q 使用长列表
Q 特定平台代码
- platform
- 特定平台扩展名
Q React
Q 常用的第三方库
Q Proguard
- Java 字节码混淆压缩工具
def enableProguardInReleaseBuilds = true
Q 打包发布
- 生成一个签名密钥
- 设置 gradle 变量
- 把签名配置加入到项目的 gradle 配置中
- 生成发行 APK 包
- 测试应用的发行版本
- 针对不同的 CPU 架构生成 APK 以减小 APK 文件的大小
- 启用 Proguard 来减少 apk 的大小(可选)
- 生成发行 AAB 包
Q 和原生端通信
- 属性