因此,在ES2015中,您可以拥有:
// Module A
export const FOO = 0;
export const BAR = 1;
// Module B
import * as AExports from 'ModuleA';
console.log(AExports.FOO); // Prints 0
在运行时枚举ModuleA的导出方式是什么?
import * as AExports from 'ModuleA';
// Are these values guaranteed to be something?
Object.keys(AExports); // If so, should I look at enumerable values?
[...AExports]; // Iterable values?
Object.getOwnPropertyNames(AExports); // Here?
据我所知,规范将其描述为“导入绑定”,但我无法从中得出更多信息。
NameSpaceImport : * as ImportedBinding
Let localName be the StringValue of ImportedBinding.
Let entry be the Record {[[ModuleRequest]]: module, [[ImportName]]: "*", [[LocalName]]: localName }.
Return a new List containing entry.