問(wèn)題求助 路由判斷(vue)

問(wèn)題簡(jiǎn)介:

  • 登陸后,后臺(tái)返回有路由列表。本地寫好的有路由列表。通過(guò)兩者對(duì)比,將相同的路由動(dòng)態(tài)加載到路由中
  • 通過(guò)for map 等進(jìn)行對(duì)比。進(jìn)入死循環(huán)
// 返回的路由列表 截取一個(gè)
  {
    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: '訂貨會(huì)管理',
      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: '購(gòu)物車管理'
        },
        component: () => import('@/view/Ordering/web-meetingCart/index.vue')
      }
    ]
  },
  • 兩者是相同的。 通過(guò)id 進(jìn)行判斷(這樣是錯(cuò)誤的。因?yàn)閕d 會(huì)變動(dòng)。但是沒(méi)什么問(wèn)題。改成其他的也可以)

如何對(duì)比兩者,避免死循環(huán)

死循環(huán)產(chǎn)生(當(dāng)本地多寫一組路由數(shù)據(jù),就會(huì)產(chǎn)生) 現(xiàn)代碼本地比返回的數(shù)據(jù)多一組。產(chǎn)生死循環(huán) 求解決

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Swift1> Swift和OC的區(qū)別1.1> Swift沒(méi)有地址/指針的概念1.2> 泛型1.3> 類型嚴(yán)謹(jǐn) 對(duì)...
    cosWriter閱讀 11,619評(píng)論 1 32
  • 1、TCP為什么需要3次握手,4次斷開(kāi)? “三次握手”的目的是“為了防止已失效的連接請(qǐng)求報(bào)文段突然又傳送到了服務(wù)端...
    杰倫哎呦哎呦閱讀 3,630評(píng)論 0 6
  • 影片的一開(kāi)始充滿了懸念,一輛汽車歪歪斜斜的呈s路線行駛在公路上,似乎隨時(shí)都有可能傾倒,而車中的中年男子神色恍惚,沾...
    孟孟妞閱讀 13,527評(píng)論 0 1
  • 初中的時(shí)候,我很喜歡看老胡博客上的“看圖說(shuō)話”文章,那時(shí)候他在博客里記錄自己和楊冪、劉詩(shī)詩(shī)的敦煌旅行,也記錄自己日...
    覆盆子醬閱讀 336評(píng)論 1 0

友情鏈接更多精彩內(nèi)容