RT
14 回复
看官网文档差不多就是这个样子
app.configure(function() {
app.use(express.csrf());
//原来的dynamicHelpers
app.use(function(req, res, next) {
res.locals.csrf = req.session ? req.session._csrf : '';
next();
});
});
//原来的helpers
app.locals({ title: config.title });
app.use(function(req, res, next){
//res.locals.title = config['title']
//res.locals.csrf = req.session ? req.session._csrf : '';
res.locals.req = req;
res.locals.session = req.session;
res.locals.error = req.error;
res.locals.success = req.success;
res.locals.docs = req.docs;
next();
});//locals
我已经定义了success,但是为什么页面还报success没有定义呢?
ReferenceError: c:\node\project\microblog\views\layout.ejs:42
40|
41| <div id="container" class="container">
42| <% if (success) { %> 43|
44| <%= success %> 45|
success is not defined