快递说明here:
路由将立即匹配其路径后面的任何路径 “/”。例如:app.use('/ apple',...)将匹配“/ apple”, “/ apple / images”,“/ apple / images / news”等等。
所以,假设我有两个路由器中间件函数:
app.get('/apple', function() {});
app.get('/apple/images', function() {});
,请求是
GET http://domain.com/apple/images
所以我想要我的第二个函数来处理请求,但据我所知,第一个函数也会被调用,对吗?有没有办法跳过第一个?我知道我可以从第一个函数调用next()
:
app.get('/apple', function(req,res,next) {next()});
但是它真的应该怎么做?在这种情况下我应该使用next('router')
吗?
答案 0 :(得分:2)
订单很重要。首先定义更长的路径,然后您将获得所需的行为。