代码演示:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
</body>
<script src="https://cdn.jsdelivr.net/npm/vconsole@3.11.0/dist/vconsole.min.js"></script>
<script>
// 初始化
var vConsole = new VConsole();
console.log('vConsole init');
</script>
</html>
外部引入:
function addScript(url){
var script = document.createElement('script');
script.setAttribute('type','text/javascript');
script.setAttribute('src',url);
document.getElementsByTagName('head')[0].appendChild(script);
}
addScript("https://cdn.jsdelivr.net/npm/vconsole@3.11.0/dist/vconsole.min.js");
var vConsole = new VConsole();
console.log('vConsole init');
另一种方法:
<script src="https://cdn.jsdelivr.net/npm/eruda@2.4.1/eruda.min.js"></script>
<script>
eruda.init();
console.log('控制台打印信息');
</script>