2013-11-14 50 views
0

我想縮短我的JS,但編譯時出現錯誤。在閉包編譯時編譯時出錯

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

items: { 
    visible: 1, 
    width: 200 
     } 

華林消息:從像點

錯誤警告

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:'', 

說我如何解決這個錯誤。

+1

也許,也許,擺脫警告中提到的尾隨逗號會使警告消失。 –

回答

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

}

需求是

default = { 
    Home:'', 
    Max: 5 

}

+0

你的權利。感謝您的幫助 –

+0

@happi如果這是正確的,請接受答案。 –

0

的選項有:

  1. 調低ES3診斷小組警告或關閉

  2. 將語言模式更改爲ECMASCRIPT5ECMASCRIPT5_STRICT。 EcmaScript 5標準化的尾隨逗號行爲,但IE8及更低版本將產生語法錯誤,如果您嘗試運行代碼未編譯

  3. 更正代碼以刪除尾隨逗號。