问题求助 路由判断(vue)

问题简介:

  • 登陆后,后台返回有路由列表。本地写好的有路由列表。通过两者对比,将相同的路由动态加载到路由中
  • 通过for map 等进行对比。进入死循环
// 返回的路由列表 截取一个
  {
    id: 2,
    path: '/Article',
    name: '/Article',
    meta: {
      title: '文章管理',
      icon: '_Article_management'
    },
    component: Main,
    children: [
      {
        id: 21,
        pid: 2,
        path: 'articletype',
        name: 'articletype',
        meta: {
          title: '文章类型列表',
        },
        component: () => import('@/view/Article/articletype/index.vue')
      },
      {
        id: 22,
        pid: 2,
        path: 'article',
        name: 'article',
        meta: {
          title: '文章列表',
        },
        component: () => import('@/view/Article/article/index.vue')
      },
    ]
  }
// 本地路由表
  {
    id: 2,
    path: '/Article',
    name: '/Article',
    meta: {
      title: '文章管理',
      icon: '_Article_management'
    },
    component: Main,
    children: [
      {
        id: 21,
        pid: 2,
        path: 'articletype',
        name: 'articletype',
        meta: {
          title: '文章类型列表',
        },
        component: () => import('@/view/Article/articletype/index.vue')
      },
      {
        id: 22,
        pid: 2,
        path: 'article',
        name: 'article',
        meta: {
          title: '文章列表',
        },
        component: () => import('@/view/Article/article/index.vue')
      },
    ]
  }
  {
    id: 3,
    path: '/Ordering',
    name: '/Ordering',
    meta: {
      title: '订货会管理',
      icon: '_Ordering'
    },
    component: Main,
    children: [
      {
        id: 31,
        pid: 3,
        path: 'web-meeting',
        name: 'web-meeting',
        meta: {
          title: '主题列表'
        },
        component: () => import('@/view/Ordering/web-meeting/index.vue')
      },
      {
        id: 32,
        pid: 3,
        path: 'web-meetingStatus',
        name: 'web-meetingStatus',
        meta: {
          title: '商品上线'
        },
        component: () => import('@/view/Ordering/web-meetingStatus/index.vue')
      },
      {
        id: 33,
        pid: 3,
        path: 'web-meetingCart',
        name: 'web-meetingCart',
        meta: {
          title: '购物车管理'
        },
        component: () => import('@/view/Ordering/web-meetingCart/index.vue')
      }
    ]
  },
  • 两者是相同的。 通过id 进行判断(这样是错误的。因为id 会变动。但是没什么问题。改成其他的也可以)

如何对比两者,避免死循环

死循环产生(当本地多写一组路由数据,就会产生) 现代码本地比返回的数据多一组。产生死循环 求解决

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Swift1> Swift和OC的区别1.1> Swift没有地址/指针的概念1.2> 泛型1.3> 类型严谨 对...
    cosWriter阅读 11,135评论 1 32
  • 1、TCP为什么需要3次握手,4次断开? “三次握手”的目的是“为了防止已失效的连接请求报文段突然又传送到了服务端...
    杰伦哎呦哎呦阅读 3,511评论 0 6
  • 影片的一开始充满了悬念,一辆汽车歪歪斜斜的呈s路线行驶在公路上,似乎随时都有可能倾倒,而车中的中年男子神色恍惚,沾...
    孟孟妞阅读 13,318评论 0 1
  • 初中的时候,我很喜欢看老胡博客上的“看图说话”文章,那时候他在博客里记录自己和杨幂、刘诗诗的敦煌旅行,也记录自己日...
    覆盆子酱阅读 314评论 1 0