Sails 1.0.0(测试版)中是否存在即显消息 (req.flash)?
Does flash message (req.flash) exists in Sails 1.0.0 (beta)?
我正在尝试 Sails.js 测试版 (1.0.0-46) 并注意到即时消息不是开箱即用的:
req.flash(type, message)
我在尝试使用时收到 TypeError: req.flash is not a function 消息。
哎哟...刚刚在升级文档中找到了正确的答案 (Upgrading to v1.0)。
The connect-flash middleware has been removed (so req.flash() will no longer be available by default). If you wish to continue using req.flash(), run npm install --save connect-flash in your app folder and add the middleware manually.
运行 下面的命令:
npm install --save connect-flash
并修改config/http.js文件:
middleware: {
flash : require('connect-flash')(),
order: [
'cookieParser',
'session',
'flash', // <-- add this
// 'bodyParser',
'compress',
'poweredBy',
'router',
'www',
'favicon',
],
它在它的会话对象 req.session.flash
中,您可以将它用作
req.session.flash{type:'success', message:'your message'}
我正在尝试 Sails.js 测试版 (1.0.0-46) 并注意到即时消息不是开箱即用的:
req.flash(type, message)
我在尝试使用时收到 TypeError: req.flash is not a function 消息。
哎哟...刚刚在升级文档中找到了正确的答案 (Upgrading to v1.0)。
The connect-flash middleware has been removed (so req.flash() will no longer be available by default). If you wish to continue using req.flash(), run npm install --save connect-flash in your app folder and add the middleware manually.
运行 下面的命令:
npm install --save connect-flash
并修改config/http.js文件:
middleware: {
flash : require('connect-flash')(),
order: [
'cookieParser',
'session',
'flash', // <-- add this
// 'bodyParser',
'compress',
'poweredBy',
'router',
'www',
'favicon',
],
它在它的会话对象 req.session.flash
中,您可以将它用作
req.session.flash{type:'success', message:'your message'}