浏览器端如何使用VConsole.js调试代码?

本文介绍如何使用VConsole进行网页错误捕获与实时调试,通过实例代码展示了VConsole的引入方式及其基本使用方法,包括错误信息的捕获与打印。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>VConsole</title>
</head>
<body>
<script src='https://wechatfe.github.io/vconsole/lib/vconsole.min.js?v=3.0.0.0'></script>
<script type="text/javascript">
	window.vConsole = new window.VConsole();
	window.onerror = function(errorMessage, scriptURI, lineNumber,columnNumber,errorObj) {
	   console.log("错误信息:" , errorMessage);
	   console.log("出错文件:" , scriptURI);
	   console.log("出错行号:" , lineNumber);
	   console.log("出错列号:" , columnNumber);
	   console.log("错误详情:" , errorObj);
	}
	throw new Error("出错了!");
</script>
</body>
</html>

转载于:https://www.cnblogs.com/feixiablog/p/10254494.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值