1. 安裝
需要Node.js平台, 先安裝好后, 打開Node.js command prompt, 通過NPM來安裝 weinre
![]() |
|
npm -g install weinre
|
2. 啟動
安裝完成后, 我們接着啟動 weinre
![]() |
|
weinre -httpPort 8081 -boundHost -all-
|
![]() |
|
能打開這個地址就說明weinre啟動成功了
|
可以配置 .weinre/server.properties 讓啟動 weinre 變得更方便, 具體方法請參考官網, 配置好后, 以后想啟動 weinre, 直接運行weinre命令即可, 無需每次都追加那些參數了.
3. Instrumenting your web page to act as a debug target
將如下腳本追加到你將要調試的頁面上
<script src="http://你的IP地址:8081/target/target-script-min.js#anonymous"></script>
4. 折騰這么久, 快點讓我遠程調試吧
在手機上打開要調試頁面的地址
![]() |
在 weinre Access Points 中開始遠程調試
![]() |
|
點擊anonymous Access Points
|
![]() |
|
點擊一下激活target
|
終於可以調試了! 接下來隨便怎么玩都可以了, 大家應該都很熟練了吧...
cmd下輸入:weinre --httpPort 8080 --boundHost 10.62.0.173
手機訪問:http://10.62.0.173:8080/www/2.html
電腦也訪問:http://10.62.0.173:8080/www/2.html
[注意:若是使用無線則需要是同一個熱點。。手機和電腦都訪問同一個網址。。](www是我建立的目錄:C:\Users\lenovo\AppData\Roaming\npm\node_modules\weinre\web\www)
這只是手機訪問電腦ip的網址而已。。並沒有將手機和電腦連接到一起調試,一開始以為這就行了,后來才發現是錯的。
2. 若:cmd下輸入:weinre --httpPort 8080 --boundHost -all- [8080為端口號。。]
【注意:若為weinre --httpPort 8080 --boundHost all,則報錯weinre: unable to resolve boundHost address:all】
則電腦直接訪問 http://127.0.0.1:8080/client/
訪問文件:http://127.0.0.1:8080/www/2.html
(本地路徑:C:\Users\lenovo\AppData\Roaming\npm\node_modules\weinre\web\www)
3.測試是否成功。。
訪問:http://localhost:8080/ client/#anonymous然后頂部有一個:Targets:
<!doctype html>
<html>
<head>
<script src="http://10.62.0.173:8080/target/target-script-min.js#anonymous"></script>
<script src="../target/target-script-min.js" /></script>
</head>
<body>
<style>
body{background:#ff7300}
h3{font-size:50px;padding:100px;}
</style>
<h3>測試內容。。。。。</h3>
</body>
</html>
。。最終10.200.108.11 [channel: t-7 id: anonymous] - http://10.62.0.173:8080/www/1.html 方可。。。






