使用weinre远程调试

1、调试环境:

1)使用nodejs搭建调试服务器:

  先安装node,然后使用npm安装weinre,在node.js安装目录输入以下命令

npm install weinre

2)需要wifi环境和webkit浏览器。

2、远程调试:

 1)启动weinre服务器

d:  //在命令行中进入d盘
cd Nodejs  //进入Nodejs安装目录 此处是d:/Nodejs
node.exe node_modules\weinre\weinre --boundHost -all-  //启动weinre服务器
node.exe node_modules\weinre\weinre --boundHost  192.168.1.125   //启动weinre服务器 指定绑定的ip

2)测试

浏览器打开

http://localhost:8080

http://192.168.1.125:8080

如果访问正常,说明服务器已配置成功。

3) 调试手机页面

在要远程调试的页面中加上下面代码,即可远程调试

 <!--  远程调试 -->
<script src="http://58.198.183.20:8080/target/target-script-min.js#anonymous"></script>

或者使用收获夹快速添加调试脚本到需要调试的页面。

将以下代码添加到书签,访问需要调试的页面时,访问一下书签,即可以通过JS将调试脚本添加到当前页面,但部份浏览器不支持!

javascript:(function(e){e.setAttribute("src","http://你的调试服务器地址/target/target-script-min.js#anonymous");document.getElementsByTagName("body")[0].a(e);})(document.createElement_x_x_x_x_x_x_x("script"));void(0);

3、直接使用phoneGap的调试服务器
如果觉得服务器配置麻烦,也可以使用phoneGap现成的调试服务器。
phoneGap调试服务器地址:http://debug.phonegap.com/(相当于本机安装的http://localhost:8080)

 

posted @ 2015-03-08 14:54  freewalker  阅读(348)  评论(0编辑  收藏  举报