首页 > 其他 > 详细

Vue中Duplicate keys detected错误

时间:2020-07-08 00:44:38      阅读:1000      评论:0      收藏:0      [点我收藏+]
错误如下

拿到公司一个小哥哥的代码,一来就报了一堆bug,吓得我先写一篇博客

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,但是项目急着要,所以就先加了一个前缀index处理
    原代码:
<sidebar-item v-for="(route, index) in permission_routes" :key="route.path" :item="route" :base-path="route.path" />  
  • 解决:
<sidebar-item v-for="(route, index) in permission_routes" :key="index + route.path" :item="route" :base-path="route.path" />

Vue中Duplicate keys detected错误

原文:https://www.cnblogs.com/serahuli/p/13264096.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!