Google闭包变量window/event/console/...未声明错误 [英] Google closure variable window/event/console/... is undeclared error

查看:104
本文介绍了Google闭包变量window/event/console/...未声明错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Google Closure编译我的HTML5项目之一.我收到一些我不知道如何解决的错误.实际上,这是相同的错误,只是针对不同的变量.

I'm trying to compile one of my HTML5 project using Google Closure. I'm recieving several errors that I don't know how to solve. In fact, it's the same error but for different variables.

以下是错误消息:

未声明变量窗口 未声明可变事件 未声明变量控制台 变量音频未声明

variable window is undeclared variable event is undeclared variable console is undeclared variable Audio is undeclared

这些变量是Javascript内置变量.如果我直接在命令行中编译同一项目,那么它将起作用.但是,就我而言,我需要使用一个ant文件来编译该项目(构建过程).我的蚂蚁构建脚本使用的是与命令行中相同的jar文件.如果使用了warnings ="verbose"选项,则它不起作用.如果我删除它,它会起作用.如果我想使用警告选项"verbose",我该怎么办?请告诉我区别.

These variables are Javascript built-in variables. If I compile this same project directly in command-line, it works. But, in my case, I need to compile this project using an ant file (build process). My ant build script is using the same jar file that I use in command-line. With the option warnings="verbose", it doesn't work. If I remove it, it works. If I would like to use the option warnings-"verbose", what I have to do? Please explain me the difference.

有人可以帮我吗? 谢谢!

Could somebody help me please? Thank you!

推荐答案

-warnings = verbose选项将编译器设置为忍者模式";即文件中的每个变量都应正确声明(带注释!).例如, window 变量对于编译器是未知的,但是Closure具有window的实现(独立于所使用的平台).如果您的变量包含在其他文件中,请使用 externs .如果您仍然希望使用详细模式而不会出现未声明变量"错误,请使用标志-jscomp_off = checkVars

The option --warnings=verbose sets the compiler to "ninja mode"; i.e. every single variable in your file should be declared (an annotated!) correctly. For example, the window variable is unknown to the compiler, but Closure has an implementation of window (independent of the platform used). If your variables are included in some other file, use externs. If yo still want to use Verbose mode without the 'undeclared variable' error, use the flag --jscomp_off=checkVars

这篇关于Google闭包变量window/event/console/...未声明错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆