[英]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.