markdown ES2015 +导入/导出语法

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown ES2015 +导入/导出语法相关的知识,希望对你有一定的参考价值。

## Export Syntax

```js
// default exports
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 {}

// variables exports
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 {}

// named exports
export {};
export {foo};
export {foo, bar};
export {foo as bar};
export {foo as default};
export {foo as default, bar};

// exports from
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 Syntax

```js
// default imports
import foo from "foo";
import {default as foo} from "foo";

// named imports
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";

// glob imports
import * as foo from "foo";

// mixing imports
import foo, {baz as xyz} from "foo";
import foo, * as bar from "foo";

// just import
import "foo";
```

以上是关于markdown ES2015 +导入/导出语法的主要内容,如果未能解决你的问题,请参考以下文章

ES2015“导入”在带有 --harmony_modules 选项的节点 v6.0.0 中不起作用

Visual Studio 2015 JSX/ES2015 语法高亮

Jest + ES2015 导入

为啥必须在 ES2015 中指定导出的类型(let、var、const...)?

10分钟了解ES6+(ES2015-ES2019)那些重要的特性

从 Node.js 导入断言的 TypeScript 2.0 / ES2015 方式是啥?