VSCode怎么配置React Native开发环境
这次给大家带来VSCode怎么配置React Native开发环境,VSCode配置React Native开发环境的注意事项有哪些,下面就是实战案例,一起来看一下。
本文介绍了VSCode 配置React Native开发环境的方法,分享给大家,具体如下:
1.安装VSCode
2.安装插件
按F1 并输入 ext install 并回车, 或者使用
输入react-native安装React Native Tools
假定你已经在设备上安装了react native,
如果没有安装,请使用npm install -g react-native-cli安装
或者按照官方文档操作
新建一个RN工程 并使用VSCode打开
安装完成后 按F1可以看到命令里多了很多关于React Native的选项
React Native Command
3.配置调试环境
a.自动配置
键入shift+cmd+D或者点击icon
shift+cmd+D
选择 React Native:
会自动生成launch.json文件,里面4个配置选项Debug Android、Debug iOS、Debug iOS、Debug iOS
{ "version": "0.2.0", "configurations": [ { "name": "Debug Android", "program": "${workspaceRoot}/.vscode/launchReactNative.js", "type": "reactnative", "request": "launch", "platform": "android", "sourceMaps": true, "outDir": "${workspaceRoot}/.vscode/.react" }, { "name": "Debug iOS", "program": "${workspaceRoot}/.vscode/launchReactNative.js", "type": "reactnative", "request": "launch", "platform": "ios", "target": "iPhone 5s", "sourceMaps": true, "outDir": "${workspaceRoot}/.vscode/.react" }, { "name": "Attach to packager", "program": "${workspaceRoot}/.vscode/launchReactNative.js", "type": "reactnative", "request": "attach", "sourceMaps": true, "outDir": "${workspaceRoot}/.vscode/.react" }, { "name": "Debug in Exponent", "program": "${workspaceRoot}/.vscode/launchReactNative.js", "type": "reactnative", "request": "launch", "platform": "exponent", "sourceMaps": true, "outDir": "${workspaceRoot}/.vscode/.react" } ] }
b. 手动配置
接下来 我们清空 configurations
点击添加配置按钮,并选择configuration
添加配置
结果如下:
{ "version": "0.2.0", "configurations": [ ] }
在此点击添加配置按钮,选择React Native: Debug iOS
配置选项
这样 运行iOS就配置好了
{ "version": "0.2.0", "configurations": [ { "name": "Debug iOS", "program": "${workspaceRoot}/.vscode/launchReactNative.js", "type": "reactnative", "request": "launch", "platform": "ios", "sourceMaps": true, "target": "iPhone 6s", "outDir": "${workspaceRoot}/.vscode/.react" } ] }
点击设置左边的选项,会有Debug iOS选项
Debug iOS
接下来 就可以点击上面选项的运行按钮,成功运行iOS啦
Hello world
相信看了本文案例你已经掌握了方法,更多精彩请关注其它相关文章!
推荐阅读:
以上就是VSCode怎么配置React Native开发环境的详细内容,更多请关注其它相关文章!
上一篇: 关于后期静态绑定,该怎么解决
下一篇: php数组处置
推荐阅读
-
React Native搭建基础环境+Redux全局配置
-
在VSCode中如何配置Python开发环境
-
Visual Studio怎么重新配置开发环境?
-
Go语言系列:(1)在VsCode中配置Go的开发环境
-
pyqt5+vscode开发环境配置及编写一个实例程序
-
VSCode, Django, and Anaconda开发环境集成配置[Windows]
-
VSCode配置react开发环境的步骤
-
VSCode 配置C++开发环境
-
Visual Studio Code (VSCode) 配置搭建 C/C++ 开发编译环境的流程
-
vscode(Visual Studio Code)配置PHP开发环境的方法(已测)