繁体   English   中英

Express JS中的Jade不是渲染

[英]Jade in Express JS is not Rendering

我使用输入(name =“name”)来自from的用户名。

我用console.log(res.body.name)检查了这个名字。 即使res.send(“消息”)正在工作,但玉无法正常工作。

我的index.js

var express = require('express');
var app = express();
var router = express.Router();

router.post('/', function(req, res){
    var user = req.body.name; 
    if(user) {
            console.log('User Exist');
            res.render('show_message', {message: "User exist", type: "UserExist"});
        }
    else {
            console.log('User is New');
            res.render('show_message', {message: "User Doesn't exist", type: "NoUserExist"});
      }

}

module.exports = router;

show_message.jade

html
head
    title Person
body
    if(type=="LoginSuccess")
        h3(style="color:green") #{message}

    if(type=="error")
        h3(style="color:red") #{message}

    if(type == "success")
        h3 New person, name: #{person.name}, Registered

    if(type == "NoUserExist")
        h3(style="color:red") #{Message}

    if(type == "UserExist")
            h3(style="color:red") #{Message}

玉不渲染。 一个空白的网页即将到来。

变量区分大小写 - {message}而不是{Message}

if(type == "NoUserExist")
    h3(style="color:red") #{message}

if(type == "UserExist")
        h3(style="color:red") #{message}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM