Javascript Can';由于Jquery';新元未申报

Javascript Can';由于Jquery';新元未申报,javascript,jquery,ant,google-closure-compiler,Javascript,Jquery,Ant,Google Closure Compiler,我试图让Google Closure编译器编译我使用Jquery的javascript代码,但我一直得到变量$is undeclared有没有办法让它看到$variable。闭包编译器是否有办法查看Jquery库而不编译它。 这是我的ant脚本 <?xml version="1.0"?> <project basedir="." default="compile"> <taskdef name="jscomp" classname="com.google.java

我试图让Google Closure编译器编译我使用Jquery的javascript代码,但我一直得到变量$is undeclared有没有办法让它看到$variable。闭包编译器是否有办法查看Jquery库而不编译它。 这是我的ant脚本

<?xml version="1.0"?>
<project basedir="." default="compile">

<taskdef name="jscomp" classname="com.google.javascript.jscomp.ant.CompileTask"
       classpath="build/compiler.jar"/>

<target name="compile">

<jscomp compilationLevel="simple" warning="verbose" 
        debug="false" output="output/file.js">

  <sources dir="${basedir}/src">
    <file name="js.js"/><!-- the file I'm trying to compile -->
  </sources>

</jscomp>

</target>

</project>

我的Jquery库名为min.js,它与js.js一起位于src文件夹中


我相信这是一个简单的问题,但我只是错过了一些东西。提前谢谢

您的情况中似乎没有包含默认外部程序

此链接将使您更好地了解:
您需要包括jQuery外部程序。jQuery的每个主要版本都有自己的外部文件。你可以在

下载适当的extern后,您将在编译时如何引用它:

<?xml version="1.0"?>
<project basedir="." default="compile">

<taskdef name="jscomp" classname="com.google.javascript.jscomp.ant.CompileTask"
       classpath="build/compiler.jar"/>

<target name="compile">

<jscomp compilationLevel="simple" warning="verbose" 
    debug="false" output="output/file.js">

  <sources dir="${basedir}/src">
    <file name="js.js"/><!-- the file I'm trying to compile -->
  </sources>

  <externs dir="${basedir}/src">
    <file name="jquery-1.7.js"/>
  </externs>
</jscomp>

</target>


,其中提到将jQuery声明为一个外部环境,例如默认外部环境arn't included必须明确排除默认外部环境(默认情况下包括它们)。缺少的是必须手动包含的jQuery外部程序。我不清楚为什么“简单”模式需要外部程序。Google自己的closure compiler服务似乎让我不用jquery外部程序进行编译。@Jederikb不幸的是,closure compiler web服务以针对演示优化的模式运行,不建议用于产品编译。通过使用
第三方
标志,它假定所有未声明的符号都是外部的。您还可以将
警告级别
选项设置为
安静