【问题标题】:Printing out errors in EJS在 EJS 中打印错误
【发布时间】:2017-07-12 09:03:10
【问题描述】:

我在 EJS 中打印错误时遇到问题,因为当我在 ejs 中使用时,我被定向到找不到错误 404。谁能告诉我它是怎么打印出来的?

req.checkBody('login', 'Login is required').notEmpty();
  req.checkBody('password', 'Password is required').notEmpty();

  var errors = req.validationErrors();

  if (errors) {
    console.log(errors)
    res.render('index', {
      errors: errors
    });

【问题讨论】:

    标签: node.js ejs


    【解决方案1】:

    你需要先初始化错误。例如:索引页面的get-method中的res.render('index'),{errors: null});

    【讨论】:

      猜你喜欢
      • 2018-10-09
      • 2022-10-22
      • 1970-01-01
      • 1970-01-01
      • 2018-08-09
      • 2014-12-01
      • 2021-01-11
      • 1970-01-01
      相关资源
      最近更新 更多