flash is not defined
发布于 9 年前 作者 aeolusheath 4656 次浏览 最后一次编辑是 8 年前 来自 问答

1,不是express版本问题 app.js文件里面 …其他代码 var routes = require(’./routes/index’);

	var flash =require('connect-flash');
	console.log(flash());// 输出的是 [Funcion]
    console.log(flash);//输出的是  Function:flash
    ...其他代码
	
	app.use(flash());
	routes(app);
	module.exports=app;

2,其中路由index内容如下 module.exports = function(app) { app.post(’/reg’, function (req, res) { var name=req.body.name, password=req.body.password, password_re=req.body[‘password_repeat’], email=req.body[‘email’];

   if(!name){
 	req.flash('error','用户名怎么能为空?');  //到这里 会报flash的错误
 	return res.redirect('/reg');
 }
  });

} 求解····

2 回复

flash is not defined

ReferenceError: flash is not defined at D:\Program Files\nodejs\node_global\blog\routes\index.js:66:20

求帮助啊

回到顶部