博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【前端学习笔记】2015-09-09~~~~nodejs中的require()和module.exports
阅读量:4502 次
发布时间:2019-06-08

本文共 293 字,大约阅读时间需要 1 分钟。

nodejs中一个js文件就可以看做是一个模块

在node环境中,可以直接var a=require('模块路径以及不带扩展名的模块名')

exports---module.exports

其中node准备好了module变量,

var module={

  id:'hello',

  exports:{}

};

输出模块变量,最好都用module.exports=''或者函数;当赋值不是函数或者数组时,可以对exports直接赋值,建议统一使用module.exports=进行赋值

转载于:https://www.cnblogs.com/zipon/p/4795685.html

你可能感兴趣的文章
关于“using namespace std”
查看>>
数据可视化(Echart) :柱状图、折线图、饼图等六种基本图表的特点及适用场合...
查看>>
IDEA 报错记录
查看>>
Yii中validator之scenario
查看>>
ie11兼容
查看>>
deprecated conversion from string constant to 'char*''
查看>>
(二)scala构造器和伴生对象
查看>>
MVC中使用RemoteAttribute异步远程验证
查看>>
ROP----The Solution For Ret2shellcode
查看>>
6 个设计原则分别是什么?每种设计原则体现的设计模式是哪个?
查看>>
js判断字符串是否有重复
查看>>
mac 安装ant
查看>>
图层混合模式之正片叠底、滤色
查看>>
环信java后台发送消息时提示msg 应该为JSONObject 的坑
查看>>
Delphi中TStringList类常用属性方法详解
查看>>
删除centos7中自带有python2.7
查看>>
Cisco IOS Debug Command Reference Command E through H
查看>>
Python处理时间 time && datetime 模块
查看>>
sql 删除所有表
查看>>
SGU107-987654321 problem
查看>>