码迷,mamicode.com
首页 > Web开发 > 详细

node.js 导出当前模块的内部成员

时间:2017-05-18 20:07:51      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:exp   cti   span   nod   class   code   node   node.js   常量   

 

 

//当前模块三个成员
//1:常量
const PI = 3.14;
//2:二个方法
//计算面积
function getSize(r){
  return PI * r * r; 
}
//计算周长
function getPerimeter(r){
  return PI * r * 2;
}
//导出当前模块的内部成员,供其它模块使用
//exports.size = getSize;
//exports.perimeter = getPerimeter;

//导出当前模块 node提供二种
module.exports.size = getSize;
module.exports.perimeter = getPerimeter;

//Nodejs底层代码 exports = module.exports
//module.exports 全称
//exports        简写

 

node.js 导出当前模块的内部成员

标签:exp   cti   span   nod   class   code   node   node.js   常量   

原文地址:http://www.cnblogs.com/web-fusheng/p/6875062.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!