目录
Module语法
export
命令
分别导出
export const x = 9;
export const y = () => {
console.log(`x = ${x}`);
};
统一导出
const x = 9;
const y = () => {
console.log(`x = ${x}`);
};
export {
x,
y
};
默认导出
export default {
x: 9,
y: (x) => {
console.log(`x = ${x}`);
}
};
import
命令
通用方式
import * as m from './js/common.js';
结构方式,可以选择性导入需要的对象
import {x, y} from './js/common.js';
import {x as xx, y as yy} from './js/common.js'; // 重命名
import {default as m} from './js/common.js'; // 针对默认导出
简便方式(仅支持默认导出)
import m from './js/common.js';
标签:ECMAScript6,总结,const,导出,js,语法,export,common,import
From: https://www.cnblogs.com/javalouvre/p/17362685.html