在关闭编译器上编译时出错

时间:2013-11-14 20:48:32

标签: jquery google-closure-compiler

我想缩短我的JS,但编译时会出现错误。

来自以下各点的错误警告:

default = {
        Home:'',
        Max: 5,
}

items: {
     visible: 1,
     width: 200
      }

Waring Msg:

JSC_TRAILING_COMMA: Parse error. IE8 (and below) will parse trailing commas in array and object literals incorrectly. If you are targeting newer versions of JS, set the appropriate language_in option. at line 162 character 0
visible: 1,

JSC_TRAILING_COMMA: Parse error. IE8 (and below) will parse trailing commas in array and object literals incorrectly. If you are targeting newer versions of JS, set the appropriate language_in option. at line 249 character 0
Home:'',

说我如何解决这个错误。

2 个答案:

答案 0 :(得分:3)

default = {
    Home:'',
    Max: 5,

}

需要

default = {
    Home:'',
    Max: 5

}

答案 1 :(得分:0)

您的选择是:

  1. ES3诊断组关闭为警告或关闭

  2. 将语言模式更改为ECMASCRIPT5ECMASCRIPT5_STRICT。 EcmaScript 5标准化尾随逗号行为,但如果您尝试运行未编译的代码,则IE8及更低版本将产生语法错误

  3. 更正代码以删除尾随逗号。