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

{
  "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: '首页',   }
      }]
    }
阅读 1.5k
1 个回答

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

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题