首页 > 移动平台 > 详细

app.use

时间:2016-02-26 11:49:04      阅读:242      评论:0      收藏:0      [点我收藏+]

app.use

  Mounts the middleware function(s) at the path. If path is not specified, it defaults to “/”.

  A route will match any path, which follows its path immediately with a “/”. For example: app.use(‘/apple‘, ...) will match “/apple”, “/apple/images”, “/apple/images/news”, and so on.

  req.originalUrl in a middleware is a combination of req.baseUrl and req.path, as shown in the following example.

  技术分享

  技术分享

  Middleware functions are executed sequentially, therefore the order of middleware inclusion is important.

  技术分享

  路径可以是 path、path pattern、regular expression.

  Disable logging for static content requests by loading the logger middleware after the static middleware:

  技术分享

参考:http://www.expressjs.com.cn/4x/api.html#app.use

__dirname

  nodejs中的全局变量。

  The name of the directory that the currently executing script resides in.

 

  Example: running node example.js from /Users/mjr

  技术分享

  __dirname isn‘t actually a global but rather local to each module.

 

app.use

原文:http://www.cnblogs.com/tekkaman/p/5219616.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!