【问题标题】: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 拒绝显示它。我在这里有什么选择吗?
【问题讨论】:
标签:
javascript
internet-explorer-11
vue.js
【解决方案1】:
Jeff 已经在他的评论中解释了这个问题(IE 缺乏对<template> 的支持)。
解决这个问题的一种老套方法是使用组件和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.
}