1 React Native简介
React Native使你只使用JavaScript也能编写原生移动应用。 它在设计原理上和React一致,通过声明式的组件机制来搭建丰富多彩的用户界面。
2 沙盒模式环境搭建
官方链接 : https://reactnative.cn/docs/getting-started.html
三步骤:
npm install -g create-react-native-app
create-react-native-app AwesomeProject
以上两步等待时间长属于正常情况

3 启动项目
cd AwesomeProject
npm start
启动成功后,给了个二维码
这里启动后,会报错!!需要android环境
参考(https://reactnative.cn/docs/getting-started.html)
4 安装android环境
配置环境变量
这里参照官方文档
https://reactnative.cn/docs/getting-started.html#安装依赖-3
启动即可
启动报错,需要新建
rn工程android目录下新建local.properties文件
sdk.dir=C:\Users\jiong\AppData\Local\Android\Sdk
没有许可请参照
http://www.it1352.com/829637.html 进行修改

再次启动
启动成功
–如果出现问题
请安装SDK Manger https://www.xiazaiba.com/html/38149.html
参照
https://reactnative.cn/docs/running-on-device/
配置下adb的path,adb在sdk中已经有了
这里连接手机,打开USB调试即可
当你的手机会显示
安装后打开
说明安装成功了!
该页面是根目录的App.js
代码如下
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/
import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View} from 'react-native';
const instructions = Platform.select({
ios: 'Press Cmd+R to reload,
' + 'Cmd+D or shake for dev menu',
android:
'Double tap R on your keyboard to reload,
' +
'Shake or press menu button for dev menu',
});
type Props = {};
export default class App extends Component<Props> {
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,
},
});
问题 1
unable to load script from assets 'index.android bundle'..
https://blog.csdn.net/highboys/article/details/78513530
https://blog.csdn.net/lanmengfenghe/article/details/84675382