首页 > 代码库 > ES6 module export options 模块导出、导入语法
ES6 module export options 模块导出、导入语法
http://stackoverflow.com/questions/25494365/es6-module-export-options
A year and some later, here is the best information I‘ve found on the subject.
There are 4 types of exports. Here are usage examples of each, along with some imports that use them:
Export Syntax
// default exportsexport 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 exportsexport 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 exportsexport {};export {foo};export {foo, bar};export {foo as bar};export {foo as default};export {foo as default, bar};// exports fromexport * 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
// default importsimport foo from "foo";import {default as foo} from "foo";// named importsimport {} 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 importsimport * as foo from "foo";// mixing importsimport foo, {baz as xyz} from "foo";import foo, * as bar from "foo";// just importimport "foo";
Source.
ES6 module export options 模块导出、导入语法
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。