Phi*_*lip 0 javascript ecmascript-5 ecmascript-6
如果我使用这个函数,我会收到一个 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...');
}
);
}
Run Code Online (Sandbox Code Playgroud)
默认参数是 ES2015 的东西。
function ajaxPromise(arr = null){
var self = this;
Run Code Online (Sandbox Code Playgroud)
应该
function ajaxPromise(arr){
if (arr === undefined) {
arr = null;
}
var self = this;
Run Code Online (Sandbox Code Playgroud)
但我强烈建议使用Babel将您的源代码(以现代语法)自动转换为 ES5,而不是尝试手动完成。
| 归档时间: |
|
| 查看次数: |
28 次 |
| 最近记录: |