【发布时间】:2016-06-09 09:03:31
【问题描述】:
我希望我的模块能够导出多个函数和数值常量。 当我导入模块的所有导出属性时,我发现函数实际上并未导入。
//module1.js
const func1 = (a) => {console.log(1)};
const func2 = (b) => {console.log(2)};
const variable1 = 1;
const variable2 = 2;
export const exp1 = func1;
export const exp2 = func2;
export const exp3 = variable1;
export const exp4 = variable2;
.
//anotherFile.js
import * as module1 from './module1';
console.log(JSON.stringify(module1, null, 2)); // {"module1": {"exp3":1, "exp4":2}}
导入函数的正确方法是什么?
【问题讨论】:
标签: ecmascript-6