一年以后,这是我找到的关于该主题的最佳信息。
出口有4种类型。这是每种用法的示例,以及一些使用它们的导入:
导出语法
export default 42;
export default {};
export default [];
export default (1 + 2);
export default foo;
export default function () {}
export default class {}
export default function foo () {}
export default class foo {}
export var foo = 1;
export var foo = function () {};
export var bar;
export let foo = 2;
export let bar;
export const foo = 3;
export function foo () {}
export class foo {}
export {};
export {foo};
export {foo, bar};
export {foo as bar};
export {foo as default};
export {foo as default, bar};
export * from "foo";
export {} from "foo";
export {foo} from "foo";
export {foo, bar} from "foo";
export {foo as bar} from "foo";
export {foo as default} from "foo";
export {foo as default, bar} from "foo";
export {default} from "foo";
export {default as foo} from "foo";
导入语法
import foo from "foo";
import {default as foo} from "foo";
import {} from "foo";
import {bar} from "foo";
import {bar, baz} from "foo";
import {bar as baz} from "foo";
import {bar as baz, xyz} from "foo";
import * as foo from "foo";
import foo, {baz as xyz} from "foo";
import foo, * as bar from "foo";
import "foo";
资源。
import x from y
vsimport {x} from y