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() 调用模块的外部接口,两者的区别在于前者可以设置多个外部接口
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() 调用模块的外部接口,两者的区别在于前者可以设置多个外部接口
相关文章推荐
- 如何破解UE
- UISegmentedControl的基本用法
- Codeforces 689D Friends and Subsequences(二分+RMQ)
- 安装包时遇到 requires a peer of @angular/core、unmet peer dependency...的问题
- Android spannableStringBuilder用法整理
- Easy UI toolbar 使用html的形式添加的按钮分割线
- UICollectionView的使用小记录和一些说明
- ServletRequest.getRequestDispatcher()和ServletContext.getRequestDispather()区别
- 使用RequestUtil解析URL查询参数
- UGUI控件可拖拽移动类组件
- VUE也有自己的日历组件
- 《APUE.3E》用gdb调试ftw函数(图4-22)
- UILabel attributedText的一个坑
- easyui
- easyui的验证
- 浅谈Java设计模式(四)建造者模式(Builder)
- <java.util>PriorityQueue代码分析
- Angular-Ui-Router+ocLazyLoad动态加载脚本
- easyui--datetimebox插件,下拉框的日期不能全部显示,即一个月份中的天数未全部显示
- android测试详解_2-Building Local Unit Tests-本地单元测试