在Jade模板中显示段落

时间:2015-12-31 09:27:58

标签: node.js express pug

我已经开始研究NodeJS / Express Web应用程序示例, 我正在使用Jade模板引擎。

以下是其中一个屏幕的部分.jade代码。

html
  head
   script(src='/js/bootstrap.min.js')
   script(src='/angular/angular.min.js')
   link(href='/css/bootstrap.css' , rel='stylesheet')
 body
  div(class='container') 
      p= error

我的意图是在div中有“p”元素

<div class='container'>
<p>Error message comes here.. </p>
</div>

但是什么是happing是“p”元素在div之后

<div class='container'>
</div>
<p>Error message comes here.. </p>

请让我知道需要修改的内容,以便“p”在div中。

3 个答案:

答案 0 :(得分:0)

您的代码可能以错误的方式缩进。试试这个:

html
  head
   script(src='/js/bootstrap.min.js')
   script(src='/angular/angular.min.js')
   link(href='/css/bootstrap.css',rel='stylesheet')
 body
  .container 
    p=error

答案 1 :(得分:0)

复制了玉码,看起来你不均匀缩进。试试这个:

html
    head
        script(src='/js/bootstrap.min.js')
        script(src='/angular/angular.min.js')
        link(href='/css/bootstrap.css' , rel='stylesheet')
    body
        .container
            p error

答案 2 :(得分:0)

这对我有用

  

div.container

     
    

p =错误

  
相关问题