zoukankan      html  css  js  c++  java
  • exports 和 module.exports 的区别

    http://stackoverflow.com/questions/7137397/module-exports-vs-exports-in-node-js

    其中推荐回答:

    http://www.hacksparrow.com/node-js-exports-vs-module-exports.html

     module.exports is the real dealexports is just module.exports's little helper. Your module returns module.exports to the caller ultimately, not exports. All exports does is collect properties and attach them to module.exports IF module.exportsdoesn't have something on it already. If there's something attached to module.exports already, everything on exports is ignored.

    exports只是作为helper,exports做的仅仅是收集module.exports所没有的属性并把它们挂在到module.exports上,如果module.exports已有某属性,exports的该属性会被直接忽略。

    As long are you don't overwrite the module.exports object with an assignment operation, anything attached to module.exports and exports will be available in the 'required' module.

    只要你不用赋值符号(=)重写module.exports 对象,任何挂在到module.exports and export的属性在required的模块里都是可用的。

  • 相关阅读:
    算法复习:字符串
    【第五天打卡。
    【第四天打卡。
    【第三天打卡。
    第二天打卡。
    【唉
    配环境到崩溃系列
    所谓环境……
    【随便吐槽
    第四天。打卡。【偷懒了两天hhhh
  • 原文地址:https://www.cnblogs.com/alexandra/p/6149226.html
Copyright © 2011-2022 走看看