Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/475.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 Firefox、Edge、Vivaldi中通过jspm的ES6错误,但在Chrome、Opera中有效_Javascript_Ecmascript 6_Jspm_Systemjs_Traceur - Fatal编程技术网

Javascript Firefox、Edge、Vivaldi中通过jspm的ES6错误,但在Chrome、Opera中有效

Javascript Firefox、Edge、Vivaldi中通过jspm的ES6错误,但在Chrome、Opera中有效,javascript,ecmascript-6,jspm,systemjs,traceur,Javascript,Ecmascript 6,Jspm,Systemjs,Traceur,根据jspm教程,我通过jspm使用ES6 在Chrome和Opera中一切正常,但console在其他浏览器中会发布各种错误 Firefox:SyntaxError:class是保留标识符,未捕获异常:SyntaxError:class是保留标识符 边缘:SCRIPT1002:语法错误,可能是未处理的拒绝[2]语法错误 维瓦尔第:意外标记=> SystemJS声明它甚至可以运行IE8+ Myjspm.config.js: System.config({ baseURL: "/", de

根据jspm教程,我通过jspm使用ES6

在Chrome和Opera中一切正常,但console在其他浏览器中会发布各种错误

Firefox:
SyntaxError:class是保留标识符,未捕获异常:SyntaxError:class是保留标识符

边缘:
SCRIPT1002:语法错误,可能是未处理的拒绝[2]语法错误

维瓦尔第:
意外标记=>

SystemJS声明它甚至可以运行IE8+

My
jspm.config.js

System.config({
  baseURL: "/",
  defaultJSExtensions: true,
  transpiler: "traceur",
  babelOptions: {
    "optional": [
      "runtime",
      "optimisation.modules.system"
    ]
  },
  paths: {
    "github:*": "jspm_packages/github/*",
    "npm:*": "jspm_packages/npm/*"
  },
  shim: {
    "packages": {
      "assets/js/lib/tabs": {
        "main": "tabby",
        "format": "global",
        "deps": "jquery",
        "exports": "$.tabby"
      },
      "assets/js/lib/select": {
        "main": "selectify",
        "format": "global",
        "deps": "jquery",
        "exports": "$.selectify"
      }
    }
  },

  map: {
    "babel": "npm:babel-core@5.8.25",
    "babel-runtime": "npm:babel-runtime@5.8.25",
    "core-js": "npm:core-js@1.2.1",
    "jquery": "github:components/jquery@2.1.4",
    "jquery-mask-plugin": "npm:jquery-mask-plugin@1.13.4",
    "jquery-validation": "github:jzaefferer/jquery-validation@1.14.0",
    "selectify": "assets/js/lib/select",
    "tabby": "assets/js/lib/tabs",
    "traceur": "github:jmcriffey/bower-traceur@0.0.91",
    "traceur-runtime": "github:jmcriffey/bower-traceur-runtime@0.0.91",
    "github:jspm/nodelibs-assert@0.1.0": {
      "assert": "npm:assert@1.3.0"
    },
    "github:jspm/nodelibs-process@0.1.2": {
      "process": "npm:process@0.11.2"
    },
    "github:jspm/nodelibs-util@0.1.0": {
      "util": "npm:util@0.10.3"
    },
    "github:jzaefferer/jquery-validation@1.14.0": {
      "jquery": "github:components/jquery@2.1.4"
    },
    "npm:assert@1.3.0": {
      "util": "npm:util@0.10.3"
    },
    "npm:babel-runtime@5.8.25": {
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:core-js@1.2.1": {
      "fs": "github:jspm/nodelibs-fs@0.1.2",
      "process": "github:jspm/nodelibs-process@0.1.2",
      "systemjs-json": "github:systemjs/plugin-json@0.1.0"
    },
    "npm:inherits@2.0.1": {
      "util": "github:jspm/nodelibs-util@0.1.0"
    },
    "npm:process@0.11.2": {
      "assert": "github:jspm/nodelibs-assert@0.1.0"
    },
    "npm:util@0.10.3": {
      "inherits": "npm:inherits@2.0.1",
      "process": "github:jspm/nodelibs-process@0.1.2"
    }
  }
});
package.json

{
  "name": "project_name",
  "version": "1.0.0",
  "description": "project_description",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "project_author",
  "license": "ISC",
  "devDependencies": {
    "glob": "^5.0.15",
    "gulp": "^3.9.0",
    "gulp-autoprefixer": "^3.0.2",
    "gulp-concat-css": "^2.2.0",
    "gulp-imagemin": "^2.3.0",
    "gulp-jspm": "^0.3.2",
    "gulp-less": "^3.0.3",
    "gulp-minify-css": "^1.2.1",
    "gulp-notify": "^2.2.0",
    "gulp-rename": "^1.2.2",
    "imagemin-pngquant": "^4.2.0",
    "jspm": "^0.16.11"
  },
  "jspm": {
    "configFile": "jspm.config.js",
    "dependencies": {
      "jquery": "github:components/jquery@^2.1.4",
      "jquery-mask-plugin": "npm:jquery-mask-plugin@^1.13.4",
      "jquery-validation": "github:jzaefferer/jquery-validation@^1.14.0"
    },
    "devDependencies": {
      "babel": "npm:babel-core@^5.8.24",
      "babel-runtime": "npm:babel-runtime@^5.8.24",
      "core-js": "npm:core-js@^1.1.4",
      "traceur": "github:jmcriffey/bower-traceur@0.0.91",
      "traceur-runtime": "github:jmcriffey/bower-traceur-runtime@0.0.91"
    }
  }
}
正如我所理解的,不顾一切地想要解决这种情况,可能有很多原因。也许有人在安装过程中遇到了类似的问题。

明白了

这是因为
jspm.config.js
shim中提供了一个插件。插件使用了
立即调用的箭头函数
表示法和word
,没有任何导出指令,因此,shim插件没有被传输到ES5

因此,与其在第三方库(shim插件)中使用ES6类,不如使用简单的原型继承来构建它


花了我几个小时才发现。

看来你的类没有被traceur传输到ES5中。为什么你的配置同时提到
babel
traceur
?@loganfsmyth:这主要是为了测试,因为我试图切换传输器。