4.0.4 • Published 9 years ago

wlh-express-flash v4.0.4

Weekly downloads
2
License
ISC
Repository
github
Last release
9 years ago

express-flash


  实现在express中调用flash,将消息发送到前段页面
  in express.js, use flash to show message to front-page(html)
npm install wlh-express-flash

使用(Usage)


  1. 后端代码(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(依赖)


  1. 需要使用session作为存储
  2. express.js

connect me(联系我)


send email to wanglihui.sjz@gmail.com(深山猎人)

4.0.4

9 years ago

4.0.2

9 years ago

4.0.0

9 years ago

3.0.0

9 years ago

2.0.0

9 years ago

1.0.0

9 years ago