1.搭建react-native 有两种形式
快速形式:适用于只有js部分
build project with native code:如果需要native代码,或者在原生native代码中需要集成react-native开发的话使用这种方式
2.expo
https://docs.expo.dev/
是基于react-native的工具链,可以让我们用js去开发安卓或ios项目。需要下载客户端到手机上。
3.环境搭建
https://reactnative.dev/docs/environment-setup
(1)快速形式
1.npm install -g expo-cli
2.expo init AwesomeProject (不要用Git bash 用本地的cmd)
3.cd AwesomeProject
4.npm start # you can also use: expo start
(2)build project with native code
1.npm install -g react-native-cli
2.安装android studio // https://developer.android.com/studio
3.在android studio上安装安卓模拟器(需要开启虚拟化,用BIOS系统)

4.在android studio打开AwesomeProject , 然后运行npm start,就可以打开虚拟器了,ctrl+m 是开发者菜单

(启项目之前先把模拟器开发,然后再运行项目)
5.需要安装的依赖
npm install react-navigation-drawer

5.1安装 react-native-vector-icons
npm install react-native-vector-icons
然后再android/app/build.gradle 中添加这一行
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

网友评论