Heim  >  Fragen und Antworten  >  Hauptteil

javascript - es6 export 的 function 不能指定参数传参吗?

//file.js
export const f = function (a,b) {
    console.log(a)
    console.log(b)
}
//main.js
import * as foo from "file.js"
foo.f(b=1);

Uncaught ReferenceError: b is not defined
//报错在 foo.f(b=1)这行.
PHP中文网PHP中文网2749 Tage vor429

Antworte allen(1)Ich werde antworten

  • 怪我咯

    怪我咯2017-04-10 16:15:17

    应该是在函数声明的时候,赋默认值吧?

    Antwort
    0
  • StornierenAntwort