找不到不是es5的javascript行
如果我使用这个函数,我会收到一个 uglify 错误,但是如果我将它注释掉,gulp 会很好地构建它。我无法使用es6。这个函数的哪一部分是“es6”部分?
function ajaxPromise(arr = null){
var self = this;
$.when.apply($,arr)
.done(function() {
console.log("hello there, inside the done method of the ajax response");
}).fail(function(){
console.log('Something went wrong...');
}
);
}
回答
默认参数是 ES2015 的东西。
function ajaxPromise(arr = null){
var self = this;
应该
function ajaxPromise(arr){
if (arr === undefined) {
arr = null;
}
var self = this;
但我强烈建议使用Babel将您的源代码(以现代语法)自动转换为 ES5,而不是尝试手动完成。