H5调试的时候,我们会使用console.log,但手机上看不到打印出来的信息。所以只好各种alert,但alert总显得不方便,页面JS报错也没提示。
1 |
|
1 | // 快速上手 |
2022-02-11 16:00 补充说明:
推荐使腾讯推出的 vConsole,通过vConsole.js 重写console方法,实现了类似于微信小程序的移动端调试效果,方便查看http请求的详细信息以及浏览器缓存信息。体验更好些。
方法一:使用 npm(推荐)
1 | $ npm install vconsole |
Import 并初始化后,即可使用 console.log 功能,如 Chrome devtools 上一样。
1 | import VConsole from 'vconsole'; |
方法二:使用 CDN 直接插入到 HTML
1 | <script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script> |
可用的 CDN:
https://unpkg.com/vconsole@latest/dist/vconsole.min.js
https://cdn.jsdelivr.net/npm/vconsole@latest/dist/vconsole.min.js
测试CDN
http://img.liunwcj.cn/debug.jshttp://img.liunwcj.cn/debug.min.js
参考
debug:
https://github.com/binnng/debug.js
http://binnng.github.io/debug.js
http://binnng.github.io/debug.js/demo/index.htmlvConsole: