相关疑难解决方法(0)

Vue:模板不能键控,但不能用 div 替换模板 - 需要没有包装 div 元素的 v-for,嵌套 v-for 循环

我有这个 JSON:

{
   "data":{
      "1":{
         "color":"red",
         "size":"big"
      },
      "2":{
         "color":"red",
         "size":"big"
      },
      "3":{
         "color":"red",
         "size":"big"
      },
      "4":{
         "color":"red",
         "size":"big"
      },
      "5":{
         "color":"red",
         "size":"big"
      }
   }
}
Run Code Online (Sandbox Code Playgroud)

我用这个vue代码显示:

<template>
...

<template v-for="(obj, pos) in this.breakdown" :key="pos">
    <table class="table-auto" >
        <thead>
            <tr>
                <th class="px-4 py-2">Property</th>
                <th class="px-4 py-2">Value</th>
            </tr>
        </thead>

        <tbody>
            <template v-for = "(obj2, pos2) in obj" :key="pos2">
                <tr>
                    <td class="border px-4 py-2">
                        {{pos2}}
                    </td>
                    <td class="border px-4 py-2">
                        {{obj2}}
                    </td>
                </tr>
            </template>
        </tbody>
    </table>
</template>
...
</template>
Run Code Online (Sandbox Code Playgroud)

但是我得到了 …

javascript vue.js vue-component vuejs2

6
推荐指数
3
解决办法
4297
查看次数

标签 统计

javascript ×1

vue-component ×1

vue.js ×1

vuejs2 ×1