js 模块编程 module.exports require

来源:互联网 发布:淘宝卖死人穿过的衣服 编辑:程序博客网 时间:2024/06/05 07:44

和 python类似 node.js中一个文件也是一个模块

python 中 import 文件名(即模块名) 然后即可使用

http://www.runoob.com/nodejs/nodejs-module-system.html

module.exports 是node.js中模块的对外接口, 可以设置module.exports.world =function(){}或者直接 设置module.exports=function(){}

外部使用a=require('文件名') 后 分别使用a.world 和 a() 调用模块的外部接口,两者的区别在于前者可以设置多个外部接口

0 0