NodeJs中require use get typescript及其餘知識點集合 nodejs事件的監聽與事件的觸發 TypeScript學習筆記 Nodejs開發Office插件 child_pr

NodeJs的Express使用html

nodejs事件的監聽與事件的觸發

TypeScript學習筆記

深刻淺出Node.js

Nodejs開發Office插件

類百度文庫文檔上傳、轉換和展現功能項目開源代碼

-------------------------------------------------------------------------------------------------------------------------------------------node

N-blog

N-blog/book/1.1 Node.js 的安裝與使用.mdgit

 

NodeJieba是"結巴"中文分詞的 Node.js 版本實現, 由CppJieba提供底層分詞算法實現, 是兼具高性能和易用性二者的 Node.js 中文分詞組件。github

---------------------------------------------------------------------------------------------------------------------------------------------正則表達式

不一樣環境下配置文件使用

 Nodejs正則表達式函數之match、test、exec、search、split、replace使用詳解算法

Node.js中execFile,spawn,exec和fork簡介 

Node.js中spawn與exec的異同比較 

child_process 子進程

Nodejs新建博客練習(二)添加flash支持

 

nodejs開發 express路由與中間件

------------------------------------------------------------------------------------------------------------------------------express

 

app.use(path,callback)中的callback既能夠是router對象又能夠是函數segmentfault

app.get(path,callback)中的callback只能是函數app

給app.get(app.post、app.put同理)賦個路由對象是不行的,能夠將app.get()看做app.use的特定請求(get)的簡要寫法。例:ide

var express = require('express');
var app = express();
app.get('/hello',function(req,res,next){
    res.send('hello test2');

});

等同於

var express = require('express');
var app = express();
var router = express.Router();

router.get('/', function(req, res, next) {
  res.send('hello world!');
});
app.use('/hello',router);

什麼時用app.use,什麼時用app.get呢?

路由規則是app.use(path,router)定義的,router表明一個由express.Router()建立的對象,在路由對象中可定義多個路由規則。但是若是咱們的路由只有一條規則時,可直接接一個回調做爲簡寫,也可直接使用app.getapp.post方法。即

當一個路徑有多個匹配規則時,使用app.use,不然使用相應的app.method(get、post)

相關文章
相關標籤/搜索