gpt4 book ai didi

Javascript关闭编译器错误尾随逗号?

转载 作者:行者123 更新时间:2023-12-01 07:56:47 26 4
gpt4 key购买 nike

在 Google 的名为 Closure Compiler 的便捷工具中缩小 JavaScript 时它给出了以下错误(并且不会缩小任何东西):

Number of errors: 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 389 character 1 in all.js


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!
};

解决方法是删除尾随逗号。

关于Javascript关闭编译器错误尾随逗号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22895379/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com