使用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即可)