Node.JS与 ES 6中 模块的 export 与 import
在 Node.JS中
1、Node.js 提供了 exports 和 require 两个对象,其中 exports 是模块公开的接口, require 用于从外部获取一个模块的接口,即所获取模块的 exports 对象。
2、require 不会重复加载模块,也就是说无论调用多少次 require, 获得的模块都是同一个(实例)。Node.js 与 ES6 模块输出的都是值的引用。
3、exports.Hello表示通过 exports 对象把 Hello 类 export,将exports.Hel
原创
2020-05-27 18:08:31 ·
278 阅读 ·
0 评论