您的位置:首页 > 产品设计 > UI/UE

js 模块编程 module.exports require

2016-07-08 17:41 369 查看
和 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() 调用模块的外部接口,两者的区别在于前者可以设置多个外部接口
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: