router.addRoutes报错重复定义,网上的方法都试过了,如何解决?


menuArray.forEach(item => {
                // console.log(item)
                var arr = []
                for (let i in item) {
                    arr.push(item); //属性
                }
                // console.log(router.item)
                router.addRoutes(arr);
                
            })

const routes=[
    {
        path:'/',
        name:Main,
        component:Main,
        redirect:'/home',
        children:[]
    },
    {
        path:'/login',
        name:'login',
        component:Login
    }
    
]




menu: [
            {
              path: '/',
              name: 'home',
              label: '首页',
              icon: 's-home',
              url: 'home'
            },
            {
              path: '/mall',
              name: 'mall',
              label: '商品管理',
              icon: 'video-play',
              url: 'mall'
            },
            {
              path: '/user',
              name: 'user',
              label: '用户管理',
              icon: 'user',
              url: 'user'
            },
            {
              label: '其他',
              icon: 'location',
              children: [
                {
                  path: '/page1',
                  name: 'page1',
                  label: '页面1',
                  icon: 'setting',
                  url: 'Other/PageOne.vue'
                },
                {
                  path: '/page2',
                  name: 'page2',
                  label: '页面2',
                  icon: 'setting',
                  url: 'Other/PageTwo.vue'
                }
              ]
            }
          ],

img

有名字重复的?过滤一下再add