【发布时间】:2011-10-17 03:46:15
【问题描述】:
似乎如果我想移到 Nodejs 中的“下一个”函数(通常可能是 Javascript?),我无法将参数传递给下一个函数。
这就是我的意思:
app.get('/webpage', SomeFunction, NextFunction);
function SomeFunction (req, res, next) {
// Do things
next();
}
function NextFunction (req, res) {
// Do other things
}
现在,如果在SomeFunction 我要说next(req, res); 它似乎不起作用。它永远不会到达方法。显然我不能直接传递参数......但我的问题是为什么? next 函数如何知道要使用哪些参数?是因为它们的名称相同还是自动传递了第一个和第二个参数?如果NextFunction 使用blah, bleet 而不是req, res,它还能工作吗?
【问题讨论】:
标签: javascript node.js connect middleware next