美文网首页
Win10下ReactNative开发环境搭建

Win10下ReactNative开发环境搭建

作者: 水大云霄 | 来源:发表于2016-12-14 16:27 被阅读95次

1、自己下载Python与node.js安装,直接点击运行,按照提示一步步安装即可。

一、测试Python环境安装成功

cmd中输入python即可

二、测试Node.js环境安装成功

创建test.js文件
var http = require("http"); 

http.createServer(function(request, response) { 

response.writeHead(200, {"Content-Type": "text/plain"}); 

response.write("test nodjs"); 

response.end(); 

}).listen(8899); 

console.log("nodejs start listen 8899 port!");

在cmd中运行node d:\test.js

运行后再浏览器打开http://127.0.0.1:8899/测试

2、安装rn命令行

cmd中运行npm install -g yarn react-native-cli

3、安装android开发环境

这步骤小伙伴们都懂,不再说了。

4、创建第一个ReactNative项目helloWorld

在D盘上创建一个工程文件夹,然后cmd中进入该文件夹下。

运行命令react-native init helloWorld

等待创建完毕后进入项目看到有android与ios项目了。

用android studio打开项目即可

5、运行项目

出现红色界面,提示无法连接js。恭喜你已经成功运行了,只是还没搭建调试。

首先cmd进入helloWorld项目,运行react-native start,成功后在浏览器运行
http://localhost:8081/index.android.bundle?platform=android

接着在红色界面手机摇一摇会出现几个菜单,我们选择最后一条dev settings,进入点击Debug server host & port for device,在配置项里面填写自己的ip地址:8081。

最后回到手机,进行reload一下就妥了

相关文章

网友评论

      本文标题:Win10下ReactNative开发环境搭建

      本文链接:https://www.haomeiwen.com/subject/azwimttx.html