React Native 初始化项目和模拟器运行

中文官方文档:https://reactnative.cn/docs/environment-setup

英文官方文档:https://reactnative.dev/docs/getting-started-without-a-framework#step-1-creating-a-new-application

创建新项目

1、初始化

bash 复制代码
# 如果你之前全局安装过旧的react-native-cli命令行工具,请使用npm uninstall -g react-native-cli卸载掉它以避免一些冲突
npm uninstall -g react-native-cli @react-native-community/cli

# 初始化
npx @react-native-community/cli init demo

# [可选参数] 指定版本或项目模板
npx @react-native-community/cli init demo --version X.XX.X

npx命令安装了npm就可以用

2、安装js依赖

进入demo

bash 复制代码
npm i
运行

1、用Android studiod打开demo的android文件夹并build, 经过漫长...漫长...漫长的时间:

2、安装手机模拟器

安装好后,点三角形按钮:

检查时候有设备的命令:

bash 复制代码
adb devices

3、运行

bash 复制代码
npm run android

运行成功:

相关推荐
弓.长.1 天前
ReactNative for OpenHarmony项目鸿蒙化三方库:react-native-pdf — PDF文档查看器
react native·pdf·harmonyos
codingWhat1 天前
从 React 无痛过渡到 React Native
react native·react.js
弓.长.1 天前
ReactNative for OpenHarmony项目鸿蒙化三方库:react-native-flip-card — 翻转卡片组件
react native·react.js·harmonyos
弓.长.1 天前
ReactNative for OpenHarmony项目鸿蒙化三方库:react-native-shake — 摇一摇事件监听
react native·react.js·harmonyos
弓.长.1 天前
ReactNative for OpenHarmony项目鸿蒙化三方库:react-native-waterfall-flow — 瀑布流布局组件
react native·react.js·harmonyos
弓.长.1 天前
ReactNative for OpenHarmony项目鸿蒙化三方库:react-native-blurhash — 模糊占位图组件
react native·react.js·harmonyos
弓.长.1 天前
ReactNative for OpenHarmony项目鸿蒙化三方库:@react-native-ohos/image-editor
react native·react.js·harmonyos
墨狂之逸才2 天前
🛡️ React Native 截屏保护方案全网大比拼:到底该用哪个库?
react native
墨狂之逸才2 天前
📳 React Native 震动指南:Haptic Feedback vs 原生 Vibration 到底怎么选?
react native
哈__2 天前
ReactNative项目OpenHarmony三方库集成实战:react-native-device-info
javascript·react native·react.js