我正在使用 html5boilerplate 构建脚本,并在缩小脚本时(使用 Google Closure 编译器)
我收到此错误
-js.all.minify:
[echo] Minifying scripts
[copy] Copying 3 files to /Users/Username/Desktop/Web/intermediate/js
[apply] /Users/Juan/Desktop/Web/js/plugins.js:117: ERROR - Parse error. Internet Explorer has a non-standard intepretation of trailing commas. Arrays will have the wrong length and objects will not parse at all.
[apply] }, { duration: 727 })
[apply]
^
但是如果未编译运行,该代码可以在 IE 8 中运行。
这是代码
anim1.animate({
'left': '+=32px',
'filter': 'alpha(opacity=100)',
'-moz-opacity': '1',
'-khtml-opacity': '1',
'opacity': '1',
}, { duration: 727 })
如何让这段代码通过强制编译器?
谢谢
最佳答案
从对象文字中删除多余的最后一个逗号:
anim1.animate({
'left': '+=32px',
'filter': 'alpha(opacity=100)',
'-moz-opacity': '1',
'-khtml-opacity': '1',
'opacity': '1' // <-- No comma here.
}, { duration: 727 }); // <-- I'd also suggest a semicolon there.
正如 Closure 编译器所说,带有此类尾随逗号的文字无法被某些浏览器解析。
关于jquery - Internet Explorer、闭包编译器和尾随逗号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11823162/