【问题标题】:Jade is not working as expected not showing index.jade contentJade 未按预期工作,未显示 index.jade 内容
【发布时间】:2013-06-20 13:48:48
【问题描述】:

我正在尝试使用玉。我正在尝试在获取请求中呈现模板,我的代码是

app.get('/promocode/generate-promocode',mw.authenticate,function(req,res)
    {  res.render('index1', {}); 
  });

我的 layout.jade 文件代码是

doctype 5
html
  head
    block head
    title= title

    include layout/css
    include layout/headerjs

    body
      include header/main

      include layout/topbar

      .middle-content
        .container
          .wrapper
            block content

      include footer/main

      include layout/footerjs

而我的 index.jade 文件代码是

extends layout

h1 Welcome to Marketplace 
h1 Welcome to Marketplace 
h1 Welcome to Marketplace 

h1 Welcome to Marketplace 

h1 Welcome to Marketplace 

h1 Welcome to Marketplace 

当我转到页面时,它只显示 layout.jade 语法没有 h1 标题,内容为“欢迎来到市场”。有什么建议如何在 html 页面中显示这个标题标签??

【问题讨论】:

    标签: javascript node.js pug


    【解决方案1】:

    你必须在你的 index.jade 中定义相同的块,它必须被继承。

    extends layout
    block content
      h1 Welcome to Marketplace 
    

    考虑到res.render('index1', {});index.jade 中的文件名不匹配,您输入的错误是,这应该可以解决您的问题。

    【讨论】:

      猜你喜欢
      • 2015-02-05
      • 1970-01-01
      • 2021-04-22
      • 2012-06-19
      • 2014-09-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-05
      相关资源
      最近更新 更多