2017-03-26 44 views
0

闪存连接成快递我不能为什么已了解它不工作。我做成快递航线

User.createUser(newUser, function(err,user){ 
    if(err) throw err; 
    console.log(user); 
}); 

req.flash('info', 'Flash Message Added'); 

res.location('/'); 
res.redirect('/'); 

,并进入视野

- if (messages.info) 
    .message.info 
     span= messages.info 

我也跟着this example into npmjs。我做错了什么?

+0

我解决了这个问题,像这样的,但我不能已了解它是如何工作...攻玉文件我用'!=消息()'和[连接闪光](https://www.npmjs.com/package/连接闪光灯)。我发现这个例子到eduonix但不能理解... –

回答

0

如果您同时拨打res.locationres.redirect,则表示您实质上执行了两个重定向。您req.flash消息仅支左右当前页面请求,所以它只会是第一个重定向可见。重定向第二次清除您的Flash的消息,这就是为什么它可能无法显示。见this SO questionres.locationres.redirect之间的差异。