Cannot use v-for on stateful component root element because it renders multiple elements.

报错如图提示:

 Cannot use v-for on stateful component root element because it renders multiple elements.中文大致意思:不能在根元素(root element)使用 v-for,因为v-for是个循环体呈现多个元素,v-for在根元素上导致无法渲染。

代码如图:

<template>
  <div v-for="(item,index) in headerList" v-on:click="selectMainTheme(index)">
    <a href="java:;" :class="{'active':idx == index}">{{item.name}}</a>
  </div>
</template>

修改后代码:

<div class="contain">
    <div v-for="(item,index) in headerList" v-on:click="selectMainTheme(index)">
      <a href="java:;" :class="{'active':idx == index}">{{item.name}}</a>
    </div>
  </div>

猜你喜欢

转载自blog.csdn.net/dt1991524/article/details/85198468