2
我试图反式桩下面的代码babeljs的try it out标签 -static关键字在咕噜 - 巴贝尔抛出错误
class aboutController{
constructor(ajaxService){
this.ajaxService = ajaxService;
this.printLog();
}
printLog(){
this.ajaxService.log();
}
static $inject = ["ajaxService"];
}
static关键字得到的反式堆到
{
key: "$inject",
value: ["ajaxService"],
enumerable: true
}
然后我试着out grunt-babel任务来自动化构建。我gruntfile.js看起来是这样的 -
module.exports = function(grunt){
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
babel: {
options: {
sourceMap: true,
highlightCode: true
},
es6: {
files: [
{
expand: true,
src: ['components/**/*.es6'],
ext: '.js'
}
]
}
},
watch: {
scripts: {
files: ['components/**/*.es6'],
tasks:['babel']
}
}
});
require("load-grunt-tasks")(grunt);
grunt.registerTask("default", ["babel", "watch"]);
}
但现在static关键字是给错误,当我删除了static关键字,构建在流逝。任何想法如何解决这个问题。咕噜咕噜是否过时?
这里是我的packahe.json看起来像 -
{
"name": "babeles6",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"grunt": "~0.4.2",
"grunt-babel": "^5.0.1",
"grunt-contrib-watch": "^0.6.1",
"load-grunt-tasks": "^3.2.0"
}
}
感谢您指出正确的ES6 apporach。我在选项中将舞台改为0,并且像魅力一样工作。 –