我最终像这样解决了这个问题:
var appendLocalsToUseInViews = function(req, res, next)
{
//append request and session to use directly in views and avoid passing around needless stuff
res.locals.session = req.session;
next(null, req, res);
}
Run Code Online (Sandbox Code Playgroud)
然后将其添加到中间件中:
app.use(appendLocalsToUseInViews);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1785 次 |
| 最近记录: |