开发者

YUI compressor: Found an undeclared symbol

I have a collection of Javascript files that together constitute a system. Different parts of the system are in different (global) namespaces (e.g., NSA, NSB, etc.) and those namespaces may be objects, e.g.

 NSA = { 
    ... lots of stuff ..开发者_如何学Go.
 }

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:

/*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:

Found an undeclared symbol: $

and that's for using $ for 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.


The YUI library doesn't recognize Jquery, so it "thinks" its an error. Seems like it's nothing to worry about.


Add

var $ = window.$;

to your code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜