我在使用 Jade 和 express 时遇到了一些问题。这是 serder 端:
router.get('/login', function (req, res) {
res.status(200)
res.render('login',{title:'login'})
res.end()
});
这是我的 Jade :
doctype html
html(lang='en')
head
meta(charset='UTF-8')
meta(name='viewport', content='width=device-width')
title= #{title}
block css
link(rel='stylesheet', href='/css/style.css')
block js
//script(src='../public/js/')
script(src='http://localhost:35729/livereload.js')
body
block content
当然,这些是我的错误:
> 7| title= #{title}
8| block css
9| link(rel='stylesheet', href='/css/style.css')
10| block js
Unexpected token ILLEGAL
at Function (native)
at assertExpression (/Users/VeaVictis/iGym/node_modules/jade/lib/lexer.js:30:3)
at Object.Lexer.code (/Users/VeaVictis/iGym/node_modules/jade/lib/lexer.js:584:23)
还有更多,但我认为它们没有用。预先感谢大家。我借此机会祝您圣诞节快乐
最佳答案
尝试删除标题后的 = 号
应该是
title #{title}
关于javascript变量到jade模板中-服务器端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34349783/