卡在 req.flash 不是函数错误
Stuck with req.flash is not a function error
以下是我的 app.js 代码,无论我把 app.use(req.flash());
放在哪里,它都会给我这个错误,我已经为它尝试了不同的堆栈,但它不起作用
var flash = require('connect-flash');
在这个阶段,如果我向下移动路由器,它会给我一些状态错误 code:1
app.use('/', index);
app.use(session({
secret : 'abc',
saveUninitialized : true,
resave : true
}));
app.use(flash());
app.use(passport.initialize());
app.use(passport.session());
app.use(function(req, res, next) {
res.locals.sucess_msg = req.flash('sucess_msg');
res.locals.error_msg = req.flash('error_msg');
res.locals.error = req.flash('error');
next();});
以下是我的 app.js 代码,无论我把 app.use(req.flash());
放在哪里,它都会给我这个错误,我已经为它尝试了不同的堆栈,但它不起作用
var flash = require('connect-flash');
在这个阶段,如果我向下移动路由器,它会给我一些状态错误 code:1
app.use('/', index);
app.use(session({
secret : 'abc',
saveUninitialized : true,
resave : true
}));
app.use(flash());
app.use(passport.initialize());
app.use(passport.session());
app.use(function(req, res, next) {
res.locals.sucess_msg = req.flash('sucess_msg');
res.locals.error_msg = req.flash('error_msg');
res.locals.error = req.flash('error');
next();});