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的模块里都是可用的。

  • 相关阅读:
    工具类-vim在shell中卡死的情况
    tomcat日志分类
    逻辑运算
    牛客练习赛29 F 算式子
    牛客练习赛29 B
    查询
    hdu 5984
    zoj 4057
    zoj 4056
    zoj 4054
  • 原文地址:https://www.cnblogs.com/alexandra/p/6149226.html
Copyright © 2011-2022 走看看