zoukankan      html  css  js  c++  java
  • 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 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

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

    Source.

  • 相关阅读:
    C#一些定义
    顺序
    针对IE8的css hack
    js 数字,金额 用逗号 隔开。数字格式化
    Ubuntu下使用Vi是方向键变乱码 退格键不能使用的解决方法
    UBUNTU中如何获得root权限
    区分IE8 、IE9 的专属css hack
    ubuntu 安装 Sublime Text 2
    PHP执行zip与rar解压缩方法
    使用ThinkPHP时,双引号导致插入数据库经过转义的处理
  • 原文地址:https://www.cnblogs.com/wucg/p/5967691.html
Copyright © 2011-2022 走看看