Skip to Content
網頁應用程式設計--使用 Node 和 Express
book

網頁應用程式設計--使用 Node 和 Express

by Ethan Brown
December 2014
Intermediate to advanced
336 pages
6h 34m
Chinese
GoTop Information, Inc.
Content preview from 網頁應用程式設計--使用 Node 和 Express
維護
|
287
Stuff.prototype.m1 = function(req, res, next){
// 小心:'this' 不是你所預期的東西,不要使用它
next();
};
Stuff.prototype.m2 = function(){
// 我們使用 Function.prototype.bind 來將這個實例與
// 'this' 特性結合
return (function(req, res, next){
// 'this' 將不會是 Stuff 實例
next();
}).bind(this);
);
module.exports = Stuff;
這個中介軟體的使用方式:
var Stuff = require('meadowlark-stuff');
var stuff = new Stuff({ option: 'my choice' });
app.use(stuff.m1);
app.use(stuff.m2());
注意,我們可以直接連結
m1
中介軟體,但必須呼叫
m2
(它會回傳我們連結進來的中介
軟體)。
結論
當你在建構網站時,焦點通常會放在啟用上面,這很正常:因為啟用時,會有許多讓人
興奮的事情發生。但是如果你對於網站的維護不聞不問,在網站啟用時非常開心的顧
客,很快就會變成不滿意的顧客。以啟用網站的熱情來擬定維護計畫,會讓網站持續擁
有相同的體驗,讓顧客不斷回流。
283
284
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

HTML5與JAVASCRIPT WEB APPS開發實務

HTML5與JAVASCRIPT WEB APPS開發實務

Wesley Hales
jQuery Mobile建置與執行

jQuery Mobile建置與執行

Maximiliano Firtman

Publisher Resources

ISBN: 9789863474371