可能出问题的代码
<el-submenu v-for="(item,index) in $router.options.routes" :index="index+''
" v-if="item.show">
<template slot="title">{{item.name}}
</template>
<el-menu-item v-for="(item2,index2) in item.children" :index="item2.path"
:class="$route.path==item2.path?'is-active':''">{{item2.name}}
</el-menu-item>
</el-submenu>
下面是两条错误提示
warning in ./src/App.vue?vue&type=template&id=7ba5bd90&
Module Warning (from ./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js):
(Emitted value instead of an instance of Error) <el-submenu v-for="item in $router.options.routes">: component lists rendered with v-for should have explicit keys. See https://vuejs.org/guide/list.html#key fo
r more info.
warning in ./src/App.vue?vue&type=template&id=7ba5bd90&
Module Warning (from ./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js):
(Emitted value instead of an instance of Error) <el-menu-item v-for="item2 in item.children">: component lists rendered with v-for should have explicit keys. See https://vuejs.org/guide/list.html#key for more
info.
列表渲染循环中加上:key="index"