如何找到在运行时定义变量的位置?

编程入门 行业动态 更新时间:2024-10-25 14:26:56
本文介绍了如何找到在运行时定义变量的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

直到最近,我一直并排使用jQuery和YUI.有时,在回调(例如,YUI按钮)内部,$将被其他一些功能遮盖(单击以获取大版本):

I've been using jQuery and YUI side-by-side with no issues until recently. Occasionally, inside of a callback for, say, a YUI button, $ will be shadowed by some other function (click for big version):

在我的生命中,我不知道为什么会发生这种情况.是的,我知道我很安全,可以在任何地方使用jQuery或window.$而不是仅仅使用$,但这只是一种解决方法,而不是实际的解决方法.

and for the life of me, I cannot figure out why this is happening. Yes, I know I could be safe and use jQuery or window.$ everywhere instead of just $, but that's just a workaround and not an actual fix.

在运行时,如何找到这个$冒名顶替者来自何处? -例如找到它的声明位置,以及为什么它在我的流血范围内.

At runtime, how can I find where this $ impostor is coming from? - e.g. find where it's declared, and why it's in my bleedin' scope.

事实证明,此行为很容易在Stack Overflow上重现(至少在Chrome和Firefox 4中如此),因为SO使用jQuery(再次单击以查看完整大小):

It turns out that this behavior is easily reproduced (at least in Chrome and Firefox 4) right here on Stack Overflow, since SO uses jQuery (again, click for full size):

我只能将$推断为

function () { return document.getElementById.apply(document, arguments) }

必须来自控制台本身!

with再次触击.

此问题的铬错误: code.google. com/p/chromium/issues/detail?id = 70969

推荐答案

我敢保证IE中不会发生这种情况?这是我唯一能找到的提示:

I'm betting this doesn't happen in IE? This is the only hint I could find:

davidwalsh.name/dollar-functions

dam5s.tumblr/post/3079779011/bug-in-chromes-javascript-console

Chrome/Firefox/Safari中的某种错误.

Some sort of bug in Chrome/Firefox/Safari.

更多推荐

如何找到在运行时定义变量的位置?

本文发布于:2023-11-10 22:48:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1576676.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:变量   定义   位置

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!