【问题标题】:Vue.js <template> inside <tr> with IE 11带有 IE 11 的 <tr> 内的 Vue.js <template>
【发布时间】:2016-04-23 00:52:07
【问题描述】:

我有一个模板,在每个tr 中,我需要显示两个tds。这是通过这样的层次结构完成的:

tbody
  tr v-for
    template v-for
      td
      td

是的,循环中有一个循环。 Chrome 对此没有任何问题,但 IE 拒绝显示它。我在这里有什么选择吗?

【问题讨论】:

  • 模板在 IE 中根本不受支持 caniuse.com/#feat=template 。据我所知,没有办法做到这一点,您必须手动拼出 tds

标签: javascript internet-explorer-11 vue.js


【解决方案1】:

Jeff 已经在他的评论中解释了这个问题(IE 缺乏对&lt;template&gt; 的支持)。

解决这个问题的一种老套方法是使用组件和is="" 属性:

<tr v-for="thing in things">
  <td v-for="subThing in thing" is="hackyComponent" :item="subThing">

在 hackyComponent 中:

<td>{{item.a}}</td>
<td>{{item.b}}</td>

export default {
 replace: true //replaces the original <td> with the template content
               // Vue might complain about creating a "Fragment Instance" in development, but that's not a real problem.

}

【讨论】:

    猜你喜欢
    • 2018-10-10
    • 2015-10-20
    • 2015-04-27
    • 2016-03-05
    • 2019-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多