node.js
来源:互联网 发布:软件测试工作分类 编辑:程序博客网 时间:2024/05/17 04:16
node.js提供了两个对象exports和require,其中 exports 是模块公开的接口,require 用于从外部获取一个模块的接口,即所获取模块的 exports 对象。
比如希望main.js可以引用hello.js对象的成员函数,用exports把hello.js中的对象作为模块的访问接口,然后在main.js中用require(./hello)加载这个模块,就可以用hello.js中exports的对象函数了。
格式:module.exports=function(){
......
}
require方法接受以下几种参数的传递:
- http、fs、path等,原生模块。
- ./mod或../mod,相对路径的文件模块。
- /pathtomodule/mod,绝对路径的文件模块。
- mod,非原生模块的文件模块。
fs.readFile()异步
fs.readFileSyco()同步
0 0
- js node
- Node.JS:
- node js
- node.js
- node.js
- node.js
- Node.js
- node.js
- Node.js
- Node.Js
- node js
- Node.js
- node.js
- node.js
- node.js
- node.js
- node.js
- node.js
- 浅谈冒泡排序
- android---自定义ToolBar样式
- 用mybatis-gennerator插件自动生成mybatis所需要的dao、bean、mapper xml文件
- Linux 文件编程
- PHP函数 serialize()和unserialize()
- node.js
- [React]1:基本语法练习
- 概率论——卡方分布
- JavaScript ~正则表达式大全
- android studio设置自定义快捷魔板代码
- 第四周:53. Maximum Subarray
- jquery图片轮播思路
- Something about Torrents.
- sqlserver vs mysql vs oracle