Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以在不停止工作的情况下将所有数据从控制台获取到变量中。
console.log=function(e){alert(e)}
我试图从控制台获取日志,但它们从控制台中消失了。甚至有可能吗?是否可以获得所有数据,而不仅仅是.log?
您必须保留旧console.log()方法的副本并从您的自定义实现中再次调用它:
console.log()
(function(o) { // keep old log method var _log = o.log; o.log = function(e) { alert(e); _log.call(o, e); } }(console));