前言
因?yàn)樽罱恢痹谂苿?dòng)端項(xiàng)目,由于在移動(dòng)端無法打開控制臺(tái)
,所以想辦法打印調(diào)試console的數(shù)據(jù)一直苦惱。之前用的是chrome的inspect
調(diào)試,但是只能使用移動(dòng)版的chrome查看數(shù)據(jù),兼容不好,所以最近使用了vConsole
進(jìn)行調(diào)試
使用
廢話不多說,說說怎么使用的吧。
首先去下載相關(guān)的代碼,由于只需要在頁面引入一個(gè)js文件,直接去下載就可以,地址: 請(qǐng)戳我
或者使用 npm 安裝:
npm install vconsole
使用webpack,然后js代碼中
import VConsole from 'vconsole/dist/vconsole.min.js' //import vconsolelet vConsole = new VConsole() // 初始化
或者找到這個(gè)模塊下面的 dist/vconsole.min.js
,然后復(fù)制到自己的項(xiàng)目中
<head> <script src="dist/vconsole.min.js"></script></head><!--建議在 `<head>` 中引入哦~ --><script> // 初始化 var vConsole = new VConsole(); console.log('VConsole is cool');</script>
結(jié)果
點(diǎn)擊后
證明安裝成功,打開查看你的打印吧。
注意
請(qǐng)注意,VConsole
只是 vConsole
的原型
,而非一個(gè)已實(shí)例化
的對(duì)象。所以在手動(dòng) new 實(shí)例化之前,vConsole 不會(huì)被插入到網(wǎng)頁中。
官方文檔: 請(qǐng)戳我
以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持武林網(wǎng)。
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注