使用vconsole
- 引入對應的vconsole.js,移動端打開即可
使用weinre
- 全局安裝weinre
npm -g install weinre
- 創建文件夾,例如:
E:\program\mobile\weinreE:\program\mobile\weinre - 文件夾下安裝
//局部安裝
npm install weinre
//執行weinre語句
node node_modules\weinre\weinre --boundHost -all-
/* 參數說明: 1.boundHost: -all-
2.httpPort: 8081
3.reuseAddr: true
4.readTimeout: 1
5.deathTimeout: 5
其中創業參數爲:--httpPort 調試服務器端口 默認是8080(建議不使用8080,防止衝突);
--boundHost 調試服務器綁定的 IP 地址或域名 默認localhost.如果指定爲-all- 表示綁定到當前機器可以訪問的所有IP
- 瀏覽器打開連接
http://localhost:8080/client/#anonymous - 在調試文件中導入weinre的js文件
<script src="http://localhost:8080/target/target-script-min.js#anonymous"></script>
- 調試即可
使用BrowserSync
- 安裝node.js
- 在需要調試的文件目錄下安裝BrowserSync
npm install -g browser-sync
- 執行BrowserSync命令
browser-sync start --server --files "*.css, *.html"
注:多個類型文件用逗號隔開,files後爲相對路徑,相對黑窗所在位置
- 獲取電腦ip,在手機端輸入IP值後添加執行黑窗命令後彈出瀏覽器窗口的地址端口號,即可(手機端和電腦端在同一局域網內,一般鏈接一個wifi即可)