Skip to content

Instantly share code, notes, and snippets.

@XingMXTeam
Last active July 8, 2018 05:25
Show Gist options
  • Save XingMXTeam/c5d35b0e98a4cf7defd684a9eee6324c to your computer and use it in GitHub Desktop.
Save XingMXTeam/c5d35b0e98a4cf7defd684a9eee6324c to your computer and use it in GitHub Desktop.
// 导出对象
export { firstname, lastname };
// 导出变量
export const firstname = 'robin';
export const lastname = 'wieruch';
// 导入整个模块
import * as myModule from "xxx";
// 导入单个模块
import { myExport } from "xxx";
// 导入时重命名
import { reallyLongNameModule as shortName } from "xxx";
// 导入默认值
import myDefault from "xxx"
// default关键字
// 导出或者导入单个
// 强调主要的导出内容
// 需要默认的导入
// file1.js
const robin = {
firstname: 'robin',
lastname: 'wieruch',
};
export default robin;
// 导入的名字可以和导出的名字可以不一样
import developer from './file1.js';
// export和export default结合使用
const firstname = 'robin';
const lastname = 'wieruch';
const person = {
firstname,
lastname,
};
export {
firstname,
lastname,
};
export default person;
import developer, { firstname, lastname } from './file1.js';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment