【问题标题】:My table content starts fine then gets all messed up together in one line (Node.js, MongoDB)我的表格内容开始很好,然后在一行中全部搞砸了(Node.js,MongoDB)
【发布时间】:2019-02-02 05:13:32
【问题描述】:

这就是我要说的:

为什么会这样?是造型问题吗?我尝试为 tr 和 tds 添加一些宽度,它看起来一样。

这是 HTML:

<div style="overflow-x:auto">
<table>
    <thead>
        <tr>
            <th>ID</th>
            <th>Nombre</th>
            <th>Apellido</th>
            <th>Mail</th>
            <th>Confirmado</th>
        </tr>
    </thead>
<% personas.forEach(function(personas){ %>
    <tbody>
        <tr>
            <td><%=personas.id%></td>
            <td><%=personas.nombre%></td>
            <td><%=personas.apellido%></td>
            <td><%=personas.email%></td>
            <td><%=personas.confirmado%></td>
        </tr>
    </tbody>
</table>
  </div>

【问题讨论】:

    标签: html css node.js mongodb html-table


    【解决方案1】:

    foreach 的结尾必须在&lt;/tbody&gt;&lt;/table&gt; 之间

    【讨论】:

    • 做到了!也非常感谢你!
    【解决方案2】:

    &lt;tbody&gt; 之后启动forEach。例如,您想要“x”行但不想要“x”&lt;tbody&gt; 然后,结束标签应该在&lt;/tbody&gt; 之前。像这样的:

        <tbody>
        <% personas.forEach(function(personas){ %>
            <tr>
                <td><%=personas.id%></td>
                <td><%=personas.nombre%></td>
                <td><%=personas.apellido%></td>
                <td><%=personas.email%></td>
                <td><%=personas.confirmado%></td>
            </tr>
        <% }); %>
        </tbody>
    

    【讨论】:

    • 做到了!非常感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多