簡體   English   中英

Javascript Closure Compiler Error Trailing Comma?

[英]Javascript Closure Compiler Error Trailing Comma?

當谷歌通過名為Closure Compiler的方便工具中縮小JavaScript時,它會出現以下錯誤(並且不會縮小某個內容):

錯誤數:1 JSC_TRAILING_COMMA:解析錯誤。 IE8(及以下)將錯誤地解析數組和對象文字中的尾隨逗號。 如果您要定位較新版本的JS,請設置相應的language_in選項。 在all.js的第389行第1字符

theme : 'default', // The theme of the slider (default, theme1, theme2, t...

故障在哪里以及需要更改哪些以修復錯誤?

$(window).load(function(){
jQuery('#slider1').autoSlider({
    theme               : 'default',    // The theme of the slider (default, theme1, theme2, theme3)
    width               : '960',    // The width of the slider, 100% for auto full width, set to 0 it will take the width of the largest image
    autoHidePlayBtn     : true,     //

錯誤(因為害怕簡單地重寫Closure Compiler錯誤所說的內容)是IE8及以下版本無法解析具有尾隨逗號的對象文字和數組文字。

var obj = {
    a: 1,
    b: 2, // trailing comma is bad!
};

......對......

var obj = {
    a: 1,
    b: 2 // no trailing comma!
};

修復是刪除尾隨逗號。

您有三種方法可以擺脫此警告:

  1. 刪除尾隨逗號
  2. 將編譯模式(使用language_in)更改為以后的編譯模式,例如ECMASCRTIPT6或ECMASCRIPT6_STRICT(尾隨逗號在EcmaScript 5中標准化)。
  3. 將編譯器的“es3”診斷組的警告級別更改為“OFF”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM