javascript - ember-view 包装器破坏了我的 table

标签 javascript html css ember.js handlebars.js

我是 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 包装 div 造成的。

<div id="ember438" class="ember-view">
    <tr>
      <th scope="row"><!----></th>
      <td><!----></td>
      <td><!----></td>
      <td><a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="761c191e183615191b0617180f5815191b" rel="noreferrer noopener nofollow">[email protected]</a></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/

相关文章:

c# - 中继器内的语音气泡

javascript - 通过网页动态处理请求

javascript - 如何计算动态表中复选框的数量

html - Font Awesome 堆叠图标随着屏幕缩小而消失

html - DIV溢出问题

css - Bootstrap Navbar 链接即使在折叠时也会显示

javascript - 显示: none/block onclick messes up

javascript - 如何在page_load中添加javascript

javascript - 以编程方式在指令中添加指令

css - 调整窗口大小时,页脚背景图案被截断