Default export:

Default export is easy way to export a function to outside module.

//flash-message.js
export default function(message){
alert(message);
} //app.js
import flashMessage from './flast-message'; flashMessage("Hello");

Default export can only export one function pre module:

//flash-message.js
export default function(message){
alert(message);
} // Not available outside this module
function logMessage(message) {
console.log(message);
}

Using named exprots:

In order to export multiple functions from a single module, we can use naming exprots.

// flash-message.js
function alertMessage(message) {
alert(message);
} function logMessage(message) {
console.log(message);
} export {alertMessage, logMessage}; //app.js import {alertMessage, logMessage} from './flash-message'; alertMessage("Hello");
logMessage("Hello");

[ES6] Module export的更多相关文章

  1. ES6 module export options 模块导出、导入语法

    http://stackoverflow.com/questions/25494365/es6-module-export-options A year and some later, here is ...

  2. ES6 Module export与import复合使用

    export与import复合使用 基本语法 export {...} from '文件'; 等价于 import {...} from "文件": export {...} 先加 ...

  3. ES6的export与Nodejs的module.exports

    原文:https://www.cnblogs.com/lxg0/p/7774094.html module.exports与exports,export与export default之间的关系和区别 ...

  4. ES6 模块化(Module)export和import详解 export default

    ES6 模块化(Module)export和import详解 - CSDN博客 https://blog.csdn.net/pcaxb/article/details/53670097 微信小程序笔记 ...

  5. 关于common.js里面的module.exports与es6的export default的思考总结

    背景 公司项目需要裁切功能,基于第三方图片裁切组件vue-cropper(0.4.0版本),封装了图片裁切组件(picture-cut)(放在公司内部组件库,仅限于公司内部使用) 在vue-cropp ...

  6. ES6的export与Nodejs的module.exports比较

    首先我们要明白一个前提,CommonJS模块规范和ES6模块规范完全是两种不同的概念. CommonJS模块规范 Node应用由模块组成,采用CommonJS模块规范. 根据这个规范,每个文件就是一个 ...

  7. NodeJS的exports、module.exports与ES6的export、export default深入详解

    前言 决定开始重新规范的学习一下node编程.但是引入模块我看到用 require的方式,再联想到咱们的ES6各种export .export default. 阿西吧,头都大了.... 头大完了,那 ...

  8. JavaScript ES6 module 模块

    在使用JavaScript开发大型项目时,模块开发概念是一个必须考虑的问题.其目的就是通过命名空间对各类业务对象进行一定的封装,防止命名冲突. 本篇着重介绍ES6 module中的export和imp ...

  9. 深入 CommonJs 与 ES6 Module

    目前主流的模块规范 UMD CommonJs es6 module umd 模块(通用模块) (function (global, factory) { typeof exports === 'obj ...

随机推荐

  1. Helloworld和程序员人生

    转:Helloworld和程序员人生 高中时期 10 PRINT "HELLO WORLD" 20 END 大学新生 program Hello(input, output) be ...

  2. ASP.NET页面传值与跳转

    asp.net页面传值的五种方法:QueryString,Session,Application,Request.Cookies,Server.Transfer 其中Cookie和Server.Tra ...

  3. centos 下使用sublime

    CentOS 之 Sublime text3 安装及配置(不支持中文输入) sublime text 的界面友好,自动补全功能也不错. (本来用vim+php_function.txt的形式进行补全的 ...

  4. JSP九大隐式对象

    JSP九大隐式对象 request HttpServletRequest response HttpServletResponse session HttpSession application Se ...

  5. bootstrap--- 两种bootstrap multiselect组件大比拼

    http://www.cnblogs.com/landeanfen/p/5013452.html 1.第一种可以兼容IE,第二种不能兼容

  6. 一句话输出NGINX日志访问IP前十位排行

    AWK的数组字段自增加,然后取值的方法,要记得哟. 还有,SORT指定列排行,也常用的.

  7. XJOI网上同步测试DAY14 T2

    思路:先考虑在D高度的最小圆覆盖,再一层一层往下走时,可以保证圆心与最开始的圆相同的时候答案是最优的. 时间复杂度O(n) 有一个坑点,就是我用了srand(time(NULL))就T了,RP太差了. ...

  8. FlashPaper组件——api

    属性摘要 属性 说明 documentPath:String FlashPaper文件的路径. borderThickness:Number 边框宽度. borderColor:String 边框颜色 ...

  9. 1.Basic Structure

    配置: rsyslogd 配置通过rsyslog.conf file,典型的在/etc下.默认的, rsyslogd 读取/etc/rsyslog.conf 文件,这个可以通过命令行选项改变 注意 配 ...

  10. ETL工具框架开源软件

    http://www.oschina.net/project/tag/453/etl 开源ETL工具 Kettle Talend KETL CloverETL Apatar Scriptella ET ...