【问题标题】:How to trigger a new line in jade/pug?如何在玉/哈巴狗中触发新行?
【发布时间】:2018-09-15 10:30:13
【问题描述】:

我想在一个单独的表格选项卡中写几个对象属性,每个属性都在一个换行

这是我的哈巴狗表代码摘录

table#posts(style="float:right; border: 1px solid green")
        tbody  
            each post in data
                 tr
                    td(style="border: 1px solid green")='Name: ' + post.firstname + ' ' + post.lastname  + 'Date of Birth: ' + post.dob
                    td(style="border: 1px solid green") buttons                    
            else
                 tr  
                    td No posts!

我希望新行位于姓名和出生日期之间。感谢您的帮助,谢谢!

【问题讨论】:

    标签: html node.js pug


    【解决方案1】:

    添加<br />标签

    table#posts(style="float:right; border: 1px solid green")
            tbody  
                each post in data
                     tr
                        td(style="border: 1px solid green")
                          | Name: #{post.firstname + ' ' + post.lastname}
                          br
                          | Date of Birth: #{post.dob}
                        td(style="border: 1px solid green") buttons                    
                else
                     tr  
                        td No posts!
    

    您还可以在<p> 标签中包含姓名和出生日期文本

    【讨论】:

    • 我试过这个方法,它输出"'Name: ' + post.firstname + ' ' + post.lastname" 作为字符串并且不访问post数据。
    【解决方案2】:

    将文本与前面的|换行:

    table#posts(style="float:right; border: 1px solid green")
            tbody  
                each post in data
                     tr
                        td(style="border: 1px solid green")
                          | 'Name: ' + post.firstname + ' ' + post.lastname
                          br
                          | 'Date of Birth: ' + post.dob
                        td(style="border: 1px solid green") buttons                    
                else
                     tr  
                        td No posts!
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-13
      • 1970-01-01
      • 2018-01-23
      • 1970-01-01
      相关资源
      最近更新 更多