我不明白如何在Paul Irish的lightweight wrapper for console.log中使用log.history。
答案 0 :(得分:1)
只需在页面中包含JS即可。像这样:
<html>
<head>
<!-- snip -->
<script src="path/to/console/wrapper.js"></script>
</head>
<body><!-- snip --></body>
</html>
// drop this in the file referenced above
window.log=function(){log.history=log.history||[];log.history.push(arguments);if(this.console){console.log(Array.prototype.slice.call(arguments))}};
这将为您提供已记录的所有内容的反向时间顺序历史记录,存储在log.history
中。想看到记录的第一件事吗?
> log.history[0]
想要记录最后一件事吗?
> log.history.slice(-1)