gpt4 book ai didi

javascript - Ember View 包装器打破了我的 table

转载 作者:太空宇宙 更新时间:2023-11-04 14:59:15 25 4
gpt4 key购买 nike

我是 ember 的新手,正在开发一个简单的测试应用程序。我正在尝试从 json 数据动态呈现表格的行。任务相对简单。然而,每一行都是一个组件,ember 将元素包装在一个带有 ember-view 类的 div 中。我相信这会阻止我的表格正确呈现。这在 ember 中通常如何处理?

//contact-listing.hbs
<tr>
<th scope="row">{{contact.employee_id}}</th>
<td>{{contact.firstName}}</td>
<td>{{contact.lastName}}</td>
<td>{{contact.email}}</td>
<td>{{contact.telephone}}</td>
<td>{{contact.department}}</td>
</tr>

//contacts.hbs
<h1>Employees</h1>
<table class="table">
<thead>
<tr>
<th>Employee ID</th>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Telephone</th>
<th>Department</th>
</tr>
</thead>
<tbody>
{{#each model as |_contact|}}
{{contact-listing contact=_contact}}
{{/each}}
</tbody>
</table>

现在这是我要返回的标记 - 在浏览器中,所有 td 数据都呈现为内联,没有表格格式。我认为这是由于插入了 ember wrapper div。

<div id="ember438" class="ember-view">
<tr>
<th scope="row"><!----></th>
<td><!----></td>
<td><!----></td>
<td>john@company.com</td>
<td>416-555-1111</td>
<td>finance</td>
</tr>
</div>

here is what the table markup looks like

这是视觉呈现的内容:

enter image description here

最佳答案

使用:

tagName: '',

在您的组件定义中。

关于javascript - Ember View 包装器打破了我的 table ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36484788/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com