ES2015 import 详解
导入所有的导出内容
1.import * as myModule from '/modules/my-module.js';
这种import的方法,直接访问module 名即可。
导入导出内容中的单个内容
2. import {myExport} from '/modules/my-module.js';
从module 导入一个导出内容
导入导出内容中的多个内容
3. import {foo, bar} from '/modules/my-module.js';
使用更方便的别名导入导出内容
4. import {reallyReallyLongModuleExportName as shortName} from '/modules/my-module.js';
导入时重命名多个内容
5.import {
reallyReallyLongModuleExportName as shortName,
anotherLongModuleName as short
} from '/modules/my-module.js';
导入一个模块的功能影响
6.import '/modules/my-module.js';
导入默认值
有一中默认的导入方式(无论它是对象,函数,类),可以使用导入语句导入此类默认值
7.import defaults from '/modules/my-module.js';