标签 模块 下的文章

Node.js 模块

Node.js 里有原生模块和文件模块, Node.js 可以使用 require() 包含其它文件里的功能, 然后使用 require 返回的对象调用模块里的公共方法; 加载模块 使用 require() 加载, 参数有以下四种 加载原生模块, 直接写模块名, 如 "http" 模块的相对路径 模块的绝对路径 要加载的文件的路径 创建自己的模块 module.exports exports 如果没有 module.exports 的话, exports 可以修饰多个接口, 返回时把这若干个接口整合成一个 module.exports; 如果 module.exports 和 exports 共存, 且 使用 module.exports引入对象, exports ...