Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/463.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 预期标识符-IE11中脚本的非ES6版本出现错误_Javascript_Babeljs - Fatal编程技术网

Javascript 预期标识符-IE11中脚本的非ES6版本出现错误

Javascript 预期标识符-IE11中脚本的非ES6版本出现错误,javascript,babeljs,Javascript,Babeljs,我正试图弄明白为什么一个脚本在IE 11中给了我错误。我已将其精简为: /* * enter-view.js is library */ (function (factory) { if (typeof define === 'function' && define.amd) { define(factory); } else if (typeof module !== 'undefined' && module.exports) {

我正试图弄明白为什么一个脚本在IE 11中给了我错误。我已将其精简为:

/*
 * enter-view.js is library
 */

(function (factory) {
  if (typeof define === 'function' && define.amd) {
    define(factory);
  } else if (typeof module !== 'undefined' && module.exports) {
    module.exports = factory();
  } else {
    window.enterView = factory.call(this);
  }
})(function () {
  const lib = function ({
    selector,
    enter = function () {},
    exit = function () {},
    progress = function () {},
    offset = 0,
    once = false
  }) {
     // other code here - but trimmed down
  };

  return lib;
});
错误代码为第14行第25列-即:

  const lib = function ({
我不明白为什么它会给我这个错误。有什么建议吗

顺便说一句,输出的代码来自Babel,配置如下:

{
  "plugins": [
    "babel-plugin-transform-es2015-template-literals",
    "babel-plugin-transform-es2015-arrow-functions",
    "babel-polyfill"
   ]
}

在这一行中,
const lib=function({selector,
您试图使用的是IE中不支持的。尝试使用babel编译器
const
是ES6,参数解构和默认值也是ES6properties@CertainPerformance-那么它应该是一个
var
吗?这个是用巴别塔创建的(具有向后兼容性,因此它应该能够使代码在旧版本上工作)。ES6版本中的原始行是:
const lib=({
如果它是用Babel创建的,那么您的配置是不正确的,因为它输出的代码肯定不是ES5compatible@CertainPerformance谢谢。我已经包括了我的Babel配置。也许我遗漏了什么?试着添加
@Babel/plugin transform destructuring
…因为该插件的文档指向了我包括您正在使用的语法谢谢,我实际上已经在使用babel.{“插件”:[“babel-plugin-transform-es2015-template-literals”,“babel-plugin-transform-es2015-arrow-functions”,“babel polyfill”]}`……我还应该在配置中添加什么来解决这个问题呢?不仅仅是析构函数,还有默认值。。。