Module#
Named export 和Default export#
命名导出和缺省到处的在模块化,类的时候的区别,
命名导出的模块在导入的时候需要花括号,而默认到处不需要,相当于导出多些,导入也多些
方式 | 导入 | 导出 |
---|---|---|
Dafault export | export default class User {...} |
import User from ... |
Named export | export class User {...} |
import {User} from ... |
全部导入#
import * as foo from "./foo.js"
参考资料#
Export and Import
export - JavaScript | MDN
216 24
21