简体   繁体   English

YUI压缩机:找到一个未声明的符号

[英]YUI compressor: Found an undeclared symbol

I have a collection of Javascript files that together constitute a system. 我收集了一起构成系统的Javascript文件。 Different parts of the system are in different (global) namespaces (eg, NSA, NSB, etc.) and those namespaces may be objects, eg 系统的不同部分位于不同的(全局)命名空间(例如,NSA,NSB等)中,并且这些命名空间可以是对象,例如

 NSA = { 
    ... lots of stuff ...
 }

Now, in my various modules, I may have code such as: 现在,在我的各个模块中,我可能具有如下代码:

NSA.method();

My code JSLints clean because I declare these namespaced objects in a comment at the top of the file: 我的代码JSLints干净,因为我在文件顶部的注释中声明了这些命名空间对象:

/*global dNSA NSB NSC */

When I run YUI Compressor (v 2.4.2) on these files with the -v (verbose) switch, it emits warnings about the referenced namespaced objects, such as: 当我使用-v(详细)开关在这些文件上运行YUI Compressor(v 2.4.2)时,它会发出有关所引用的命名空间对象的警告,例如:

Found an undeclared symbol: $

and that's for using $ for jQuery! 那是为jQuery使用$!

What can I do to define these variables so that YUI Compressor doesn't emit the warning, yet whatever I add can't cause a change to the object. 我该怎么做才能定义这些变量,以使YUI Compressor不会发出警告,但是我添加的任何内容都不会导致对象的更改。

The YUI library doesn't recognize Jquery, so it "thinks" its an error. YUI库无法识别Jquery,因此它“认为”它是一个错误。 Seems like it's nothing to worry about. 似乎没有什么可担心的。

Add

var $ = window.$;

to your code. 您的代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM