Vue+ElementUI 中路由Duplicate keys detected错误

Vue+ElementUI 后端系统报错

vue.runtime.esm.js?2b0e:619 [Vue warn]: Duplicate keys detected: '/system'. This may cause an update error.
found in

---> <Sidebar> at src/layout/components/Sidebar/index.vue
<Layout> at src/layout/index.vue
<App> at src/App.vue
<Root>

原因:v-for时,key值不唯一(一般出现在 v-for循环生成列表,对key值处理不当时)
下列代码一可以修改route.path
原代码:

 <sidebar-item v-for="route in routes" :key="route.path" :item="route" :base-path="route.path" />

改成

 <sidebar-item v-for="(route,index) in routes" :key="index+route.path" :item="route" :base-path="route.path" />
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容