Angular-js代码缩小错误:意外的令牌:运算符(>)

时间:2016-03-31 12:53:28

标签: angularjs operator-keyword minify

我正在尝试使用js-minify工具缩小我的angular-js代码,但它抛出异常为Error:Unexpected token:operator(>)

2 个答案:

答案 0 :(得分:1)

Why don't you use a transpiler like https://babeljs.io/ to compile your es6 code down to es5 and than minify/uglify your source code.

In this way you can continue to enjoy writing code in es6.

答案 1 :(得分:0)

箭头函数表达式是ECMAScript 2015中引入的新功能。您的minifier可能还不支持它。你提到你试图这样做:

scope.chartData[0].reduce((a, b) => a + b, 0)

您可以在没有箭头功能的情况下重写它:

scope.chartData[0].reduce(function(a, b) {
    return a + b
}, 0)