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.
我正在开发的是 java 脚本,我想将日志记录到我的代码中,但我希望能够使用一些全局变量或其他东西来打开和关闭它。
有没有办法做到这一点?
谢谢
是的,只需覆盖该方法:
var debugging=true; if (!debugging || "undefined" === typeof console.log) { console.log=function () {}; }