4.0.4 • Published 10 years ago
wlh-express-flash v4.0.4
express-flash
  实现在express中调用flash,将消息发送到前段页面
  in express.js, use flash to show message to front-page(html)npm install wlh-express-flash使用(Usage)
- 后端代码(backend)
  app.js
  var app = express();
  var expressFlash = require("express-flash");
  app.use(expressFlash());
  route.js
  exports.login = function(req, res, next) {
      res.flash.error("用户名或密码错误");
      //res.flash.info("登录成功")
      //res.flash.label("登录成功", "my_label");
      //res.flash.getMsgs("my_label")
      res.render("login");
  }
  exports.loginSuccess = function(req, res, next) {
      res.flash.info("恭喜您登陆成功");
      res.render("loginSuccess");
  }2. 前段代码  login.html
  <%=flash.getErrors()%>
  loginSuccess.html
  <%=flash.getInfos()%>
  //if you want only get lash msg
  // flash.getLashError() flash.getLastInfo()dependents(依赖)
- 需要使用session作为存储
- express.js
connect me(联系我)
send email to wanglihui.sjz@gmail.com(深山猎人)