Fork me on GitHub

Coding Poineer

Coding Poineer

Coding Poineer

Coding Poineer

Coding Poineer

Coding Poineer

Coding Poineer

Coding Poineer

Coding Poineer

Coding Poineer

Coding Poineer

浅析export * from 与 export {default} from用法

统一导入导出:可以将统一目录下的多个可导出文件统一导出

在需要导入的地方可通过解构导入即可

常见导出结构
// xxx.js
export const Aa = "a"
export const Bb = 111
export default = [1,2,3]
相当于
// import {} from "xxx"  解构导入
xxxModele.Aa = "a"
xxxModele.Bb = 111
// import anyName from 'xxx'  默认导入
xxxModele.default = [1,2,3]
会把 xxx 中所有的非default导出
export * from './xxx'
// 无法在外部 import {default} from "xxx"
需要 xxx 中导出 default
export { default } from './xxx'
// 或
export { default as alias } from './xxx'
需要 xxx 中导出 Aa、Bb
export { Aa , Bb  } from './xxx'
posted @ 2021-08-03 21:00  365/24/60  阅读(5692)  评论(0编辑  收藏  举报