Jade is not working as expected not showing index.jade content
我正在尝试使用玉。我正在尝试在获取请求中呈现模板我的代码是
1
2 3 |
app.get(‘/promocode/generate-promocode’,mw.authenticate,function(req,res)
{ res.render(‘index1’, {}); }); |
我的 layout.jade 文件代码是
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
doctype 5
html head block head title= title include layout/css body include layout/topbar .middle–content include footer/main include layout/footerjs |
我的 index.jade 文件代码是
1
2 3 4 5 6 7 8 9 10 11 |
extends layout
h1 Welcome to Marketplace h1 Welcome to Marketplace h1 Welcome to Marketplace h1 Welcome to Marketplace |
当我转到页面时,它只显示 layout.jade 语法没有 h1 标题,内容为”欢迎来到市场”。任何建议如何在 html 页面中显示此标题标签??
你必须在你的 index.jade 中定义相同的块,它必须被继承。
1
2 3 |
extends layout
block content h1 Welcome to Marketplace |
考虑到 res.render(‘index1’, {}); 和 index.jade 中的文件名不匹配,您作为错字输入,这应该可以解决您的问题。
来源:https://www.codenong.com/17215363/