Rumah > Soal Jawab > teks badan
PHP中文网2017-04-17 13:15:06
最近我也在做这个,暂时我知道两种方法:
设置个本地的变量,app.locals.user = {name: "11"}
res.render('index', {
user: {
name: "11"
}
})
if user.name
p #{user.name}
天蓬老师2017-04-17 13:15:06
Using template engines with Express
http://expressjs.com/en/guide/using-template-engines.html
jade
html
head
title!= title
body
h1!= message
js
app.get('/', function (req, res) {
res.render('index.jade', { title: 'Hey', message: 'Hello there!'});
});