1.http --- 網(wǎng)絡(luò)請(qǐng)求
? ??????????var http = require("http");
? ? ? ? ? ? var server = http.createServer(function(req,res){
????????????????????res.writeHead(200,{"Content-type":"text/html;charset=UTF-8"})
? ? ? ? ? ? ? ? ????res.end("樂(lè)樂(lè)")
? ? ? ? ? ? ?})
? ? ? ? ? ? ?server.listen(8080, () => {
? ????????????????????console.log(`App listening at port 8080`)
? ? ? ? ? ? ? })
2.url? --- 處理url地址
? ??????????var url = require('url')
????????????var?urlString?=?"http://user:password@www.baidu.com:8080/a/b?c=d&e=f#abc";?
????????????????console.log(url.parse(href))
? ??????????????console.log(obj);??
? ? ? ? ? ? ?????console.log(obj.protocol);//協(xié)議,http:??
????????????????console.log(obj.slashes);//協(xié)議后是否有雙斜杠,true??
????????????????console.log(obj.auth);//認(rèn)證或授權(quán),user:password??
????????????????console.log(obj.host);//主機(jī)名(包含端口號(hào))?www.baidu.com:8080??
????????????????console.log(obj.port);//端口號(hào),8080??
????????????????console.log(obj.hostname);//主機(jī)名?www.baidu.com??
????????????????console.log(obj.hash);//錨點(diǎn)名稱(chēng),#abc??
????????????????console.log(obj.search);//查詢的內(nèi)容(以?開(kāi)頭),?c=d&e=f??
????????????????console.log(obj.query);//查詢內(nèi)容,?c=d&e=f?,當(dāng)parse的第二個(gè)參宿為true時(shí),會(huì)將query解析為對(duì)象{?c:?'d',?e:?'f'?}??
????????????????console.log(obj.pathname);//路徑名,?/a/b??
????????????????console.log(obj.path);//把pathname和search組合起來(lái),??/a/b?c=d&e=f??
????????????????console.log(obj.href);//完整的鏈接地址,http://user:password@www.baidu.com:8080/a/b?c=d&e=f#abc?
3.queryStrings --- 處理`get/post`請(qǐng)求傳遞過(guò)來(lái)的參數(shù)
????????????????querystring模塊提供4個(gè)方法
? ? ? ? ? ? ? ? ? ? 一赵刑、querystring.parse(str,separator,eq,options)
? ??????????????????????????????????????parse這個(gè)方法是將一個(gè)字符串反序列化為一個(gè)對(duì)象恼蓬。
? ? ? ? ? ? ? ? ? ? 二维贺、2?querystring.stringify(obj,separator,eq,options)
? ??????????????????????????????????????stringify這個(gè)方法是將一個(gè)對(duì)象序列化成一個(gè)字符串,與querystring.parse相對(duì)趴生。
? ? ? ? ? ? ? ? ? ? 三、?querystring.escape(str)
? ??????????????????????????????????????escape可使傳入的字符串進(jìn)行編碼
? ? ? ? ? ? ? ? ? ? 四碍侦、querystring.unescape(str)
? ??????????????????????????????????????unescape方法可將含有%的字符串進(jìn)行解碼
4.File System --文件模塊 (另一篇單獨(dú)介紹fs文件模塊的一些使用方法)
5.Path --- 操作文件路徑模塊
? ? 一矿微、經(jīng)常用到 path.join(__dirname, './webView')? 拼接路徑
6.Global? --- 全局模塊
? ? ? ? 一、 __dirname : 文件所在的文件夾路徑
? ? ? ? 二念搬、__filename : 文件所在的路徑
? ? ? ? 三抑堡、require() : 導(dǎo)入需要的模塊
? ? ? ? 四摆出、module : 自定義模塊時(shí)用到
? ? ? ? 五、exports : 自定義模塊時(shí)用到
7.Buffer --- 專(zhuān)門(mén)存放二進(jìn)制數(shù)據(jù)的緩存區(qū)首妖。
8.Stream --- 可讀流偎漫、可寫(xiě)流等各種流,api很簡(jiǎn)單有缆,需理解運(yùn)行機(jī)制(重)
9.EventEmitter --- 事件處理(觸發(fā)器)
? ??????????????引入 events 模塊????var events = require('events');
? ? ? ? ? ? ????創(chuàng)建 eventEmitter 對(duì)象????var eventEmitter = new events.EventEmitter();
? ??????????????eventEmitter.on('test', function(foo, bar) {
? ????????????????????? console.log("我是測(cè)試用例=" + foo + ",bar="+bar );
? ? ? ? ? ? ? ? });
? ? ? ? ? ? ? ? eventEmitter.emit('test', 'LELE', 'XIXI');
? ? ? ? ? ? ? ? eventEmitter.emit('test', 'QQ', 'WW')象踊;
10.node中的jquery --------- express框架