app.js --添加路由 /test
app.use('/test',routes)
routes/index.js 添加响应
router.get('/test', function(req,res) {
res.locals.click = req.query.click;
res.render('test');
})
views/test.jade
mixin content
a(href = '/test?click=true') 测试
p #{click}
if click
+content
p a
else
extend layout
block content
+content
p b
views/layout.jade 添加样式 background-color:red
doctype html
html
head
title= title
link(rel='stylesheet', href='/stylesheets/style.css')
body(style = "background-color:red")
block content
测试:1.当输入localhost:3000/test时,click为undefined,输出 b 背景为红色 疑问:点击测试 ,click为true,应该输出 a true 没背景色才对,,为啥输出 b true 红色背景???