我正在使用 Google Closure 编译器,但出现以下错误:
ES6_FEATURE: this language feature is only supported in es6 mode: computed property. Use --language_in=ECMASCRIPT6 or ECMASCRIPT6_STRICT to enable ES6 features.
触发此错误的行是这一行:
var TheCellRef = LeadImport2ExcelLibrary['utils']['encode_cell']({ ['c']: C, ['r']: R });
基本上,我传递的是我在同一行上创建的对象。我知道我可以简单地在 JavaScript 源头中添加对 ES6 的支持,但我想知道为什么会出现此错误以及如何修复它?
最佳答案
那是因为你用的是Computed Property Names在文字对象中:
{ ['c']: C, ['r']: R }
兼容 es5 的替代品可能是:
var TheCellRef = LeadImport2ExcelLibrary['utils']['encode_cell']({ "c": C, "r": R });
关于javascript - Closure 编译器不支持 ES6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28728216/