Node.js个人理解——模块系统
Node.js模块系统 创建模块 Node.js给了两个对象 exports ——模块公开的接口 require —— 从外部获取模块的接口(获取模块的exports对象) 实例: 创建hello.js文件,代码如下: exports.world = function() { console.log('Hello World'); } 创建main.js文件,代码如下: var hello = require('./hello'); hello.world(); hello.js 通过 exports 对象把 world 作为模块的访问接口,在 main.js 中通过 requi
下载地址
用户评论