[NodeJS] 理解exports和module.exports 的关系,为什么不能直接替换exports?
根据定义,一个模块最终导出的是module.exports,而exports是对module.exports的全局引用,最初被定义为一个可以添加属性的空对象。所以导出自己定义的模块,两者在使用上有如下区别:1. module.exports = myModule// myModule.jsvar MyModule = {};MyModule.prototype.myFunc = function() { console.log("Hello World");};module
原创
2020-09-02 17:06:53 ·
397 阅读 ·
0 评论