【问题标题】:Why I cannot render pug variable through node为什么我不能通过节点渲染 pug 变量
【发布时间】:2019-06-16 00:34:18
【问题描述】:

我想问一个关于哈巴狗的简单问题:

html  
    head
        title This is my first Pug file
    body
        header
            p= paragaph
        section
            p gdghdhgdhdhdh
        footer
            cool footer with lots of copyrights.
route.get('/Artists/test',(req,res)=> {
    res.render('test.pug', {paragraph: 'Hi there'});
})

我不知道为什么“p”只是没有出现在浏览器上,但是元素的其余部分还可以

有点被这里发生的事情弄糊涂了。

【问题讨论】:

    标签: pug


    【解决方案1】:

    仔细看看你是如何调用模板的:

    res.render('test.pug', {paragraph: 'Hi there'});
                            ^^^^^^^^^
    

    然后仔细看看你是如何调用变量的:

    p= paragaph
       ^^^^^^^^
    

    paragaph 不匹配 paragraph 并且 pug 不会呈现空 div。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-18
      • 1970-01-01
      • 2017-10-15
      • 1970-01-01
      • 2023-03-04
      • 1970-01-01
      • 1970-01-01
      • 2019-01-25
      相关资源
      最近更新 更多