如何解决调用所有类方法或函数的 JQuery 侦听器
我想知道在 JQuery/JS 中,是否可以在调用函数或类方法或事件时添加全局侦听器? 这个想法是在控制台中显示名称函数/事件,以了解调试为真时调用的顺序和女巫函数/方法。
例如,现在我必须在所有函数中调用函数 debug :
var showdebug = true;
function test(){
debug();
test2();
}
function test2(){
debug();
...
}
function debug(){
if(showdebug === true){
console.log("function name called")
}
}
test();
控制台显示
test
test2
我想做的不是在每个函数中添加 debug(),我正在寻找 var showdebug = true;
if(showdebug === true){
add listener when all function / method called
and this listener call automatically debug()
}
function test(){
test2();
}
function test2(){
...
}
function debug(){
console.log("function name called")
}
test();
所以当我调用 test 时,这个监听器调用 auto 调试功能以在控制台中显示
test
test2
感谢您的帮助。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。