快递4.0中_locals和locals之间的区别

时间:2015-07-06 19:05:47

标签: javascript node.js express pug

出于某些原因,在我的jade文件中,我可以访问使用_locals设置的文件而不是本地文件?:

app.use(function (req, res, next) {
    if(req.isAuthenticated()) //true
    {
        res.locals.user = req.user;
    }else {
        res.locals.user = null;
    }
}

-console.info(_locals.user); //{_id: 5775.....4343}
-console.info(locals.user); //undefined
-console.info(user); //null

0 个答案:

没有答案