简体   繁体   English

找不到不是es5的javascript的行

[英]Cannot find the line of the javascript that is not es5

I am getting an uglify error if i use this function, however if i comment it out, gulp will build it fine.如果我使用这个 function,我会收到一个 uglify 错误,但是如果我将其注释掉,gulp 会很好地构建它。 I am unable to use es6.我无法使用 es6。 Which part of this function would be the "es6" part?这个 function 的哪一部分是“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...');
        }
    );
  }

Default parameters are an ES2015 thing.默认参数是 ES2015 的东西。

function ajaxPromise(arr = null){
    var self = this;

should be应该

function ajaxPromise(arr){
    if (arr === undefined) {
        arr = null;
    }
    var self = this;

But I'd highly recommend using Babel to transpile your source code (in modern syntax) down to ES5 automatically instead of trying to do it manually.但我强烈建议使用Babel将源代码(现代语法)自动转换为 ES5,而不是尝试手动执行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM