请教大侠有关视图传参数的问题!flash
app.get('/',function(req,res){
req.flash('error','用户已经注册');
console.log('--'+req.flash('error'));
res.render('index', { title: '首页'});
});
app.use(function(req, res, next){
//res.locals.title = config['title']
//res.locals.csrf = req.session ? req.session._csrf : '';
res.locals.user = app.get('user');
console.log(req.flash('error'));
res.locals.error = req.flash('error').length ? req.flash('error') : null ;
res.locals.success = req.flash('success').length ? req.flash('success') : null ;
next();
});//locals
日志:$ node app Express server listening on port 3000 [] –用户已经注册 GET / 304 561ms [] [] [] []
为什么在视图助手里面无法获取到error的值??
1 回复
求解,也遇到这个问题!