码迷,mamicode.com
首页 > 其他好文 > 详细

import 和 export -- ES6

时间:2017-06-12 00:41:39      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:import   efault   log   ==   pre   style   bsp   port   func   

例子:

最后返回的结果是:

{
    default: function fn2(){

    },
    foo2: 1,
    test3: {
        default: function fn3(){

        },
        foo3: 1
    }
}

 

// app.js
// import json from ‘./1.json‘;
import * as all from ‘./test2‘;
import fn2 from ‘./test2‘;

console.log(all);
console.log(all.default === fn2); // true
console.log(fn2);



// test2.js
function fn2(){
    console.log(1);
}

export default fn2;
var foo2 = 1;
export {foo2};
export * as test3 from ‘./test3‘;

// test3.js
function fn3(){
    console.log(1);
}

var foo3 = 1;
export {foo3};

export default fn3;

 

import 和 export -- ES6

标签:import   efault   log   ==   pre   style   bsp   port   func   

原文地址:http://www.cnblogs.com/zhengming2016/p/6986841.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!