首页 > es6 export 的 function 不能指定参数传参吗?

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)这行.

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


foo.f({b:1});

ref: http://es6.ruanyifeng.com/#docs/function

【热门文章】
【热门文章】