Home  >  Q&A  >  body text

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中文网2748 days ago428

reply all(1)I'll reply

  • 怪我咯

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

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

    reply
    0
  • Cancelreply