深度遍历循环去掉单引号外面的双引号应该怎么做,小白求指教?

gaochenyang
  • 72
{
  "errCode": "00000000",
  "errMsg": "SUCCESS",
  "timestamp": "1559127780939",
  "transId": "",
  "body": {
    "router": [
      {
        "path": "''",
        "component": "Layout",
        "redirect": "'/home'",
        "meta": {
          "title": "title",
          "icon": "icon"
        },
        "children": [
          {
            "path": "path",
            "name": "name",
            "component": "() => import('@/views/home/index')",
            "meta": {
              "title": "title",
              "icon": "icon"
            }
          },
          {
            "path": "path",
            "name": "name",
            "component": "() => import('@/views/home/index')",
            "meta": {
              "title": "title",
              "icon": "icon"
            }
          }
        ]
      },
      {
        "path": "''",
        "component": "Layout",
        "redirect": "'/home'",
        "meta": {
          "title": "title",
          "icon": "icon"
        },
        "children": [
          {
            "path": "path",
            "name": "name",
            "component": "() => import('@/views/home/index')",
            "meta": {
              "title": "title",
              "icon": "icon"
            }
          },
          {
            "path": "path",
            "name": "name",
            "component": "() => import('@/views/home/index')",
            "meta": {
              "title": "title",
              "icon": "icon"
            }
          }
        ]
      }
    ]
  }
}

如path:"''" ,component:"() => import('@/views/home/index')"以及redirect:"'/home'",去掉最外层双引号,这个需要怎么去遍历循环呢

过滤成以下格式:

{
      path: '',
      component: Layout,
      redirect: '/home',
      children: [{
        path: 'home',
        name: 'Home',
        component: () => import('@/views/home/index'),
        meta: {title: '首页', icon: 'home', headerText: '首页',   }
      }]
    }
评论
阅读 532
1 个回答

new Function()和eval()都可以实现 推荐用new Function

宣传栏