首页 > 其他 > 详细

es6 import笔记

时间:2018-03-21 17:13:55      阅读:174      评论:0      收藏:0      [点我收藏+]


 export输出:

 

// profile.js
var firstName = ‘Michael‘;
var lastName = ‘Jackson‘;
var year = 1958;

export {firstName, lastName, year};

 

 

function v1() { ... }
function v2() { ... }

export {
  v1 as streamV1,
  v2 as streamV2,
  v2 as streamLatestVersion
};

 

 

// main.js
import {firstName, lastName, year} from ‘./profile.js‘;

function setName(element) {
  element.textContent = firstName + ‘ ‘ + lastName;
}

 

整体加载:

import * as circle from ‘./circle‘;

console.log(‘圆面积:‘ + circle.area(4));
console.log(‘圆周长:‘ + circle.circumference(14));


 export default:

// export-default.js
export default function () {
  console.log(‘foo‘);
}

 

// import-default.js
import customName from ‘./export-default‘;
customName(); // ‘foo‘

 

es6 import笔记

原文:https://www.cnblogs.com/intbingbing/p/8617991.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!