求指点
用来做动态侧边栏 与路由权限的 若哥们做过后面的vue3路由动态添加 希望不吝赐教 (听说他要循环添加)
根据 数组来获取对应的路由信息
menuList 数组中元素对应的名字
let menuList = ["custom", "customManage", "customManageAdd", "collection",'collectionNumber'];
let routeList = [{
path: "/custom",
name: "custom",
redirect: "customManage",
meta: { title: "客户管理", icon: "kehu" },
alwaysShow: true,
children: [
{
path: "customManage",
component: () => import("@/views/custom/customManage"),
name: "customManage",
meta: { title: "客户管理", icon: "kehu" },
},
{
path: "customManage/add",
component: () => import("@/views/custom/customComponent/add.vue"),
name: "customManageAdd",
hidden: true,
meta: { title: "新增客户", icon: "" },
},
{
path: "customManage/info",
component: () => import("@/views/custom/customComponent/info.vue"),
name: "customManageInfo",
hidden: true,
meta: { title: "客户详情", icon: "" },
},
{
path: "contactsMange",
component: () => import("@/views/custom/contactsMange"),
name: "contactsMange",
meta: { title: "联系人管理", icon: "lianxiren" },
},
{
path: "contactsMange/add",
component: () => import("@/views/custom/contactsComponent/add.vue"),
name: "contactsMangeAdd",
meta: { title: "新增联系人", icon: "" },
hidden: true,
},
],
},
{
path: "/collection",
name: "collection",
redirect: "collectionNumber",
meta: { title: "收款公司", icon: "yinhangka" },
alwaysShow: true,
children: [
{
path: "collectionNumber",
component: () => import("@/views/collection/collectionNumber"),
name: "collectionNumber",
meta: { title: "收款公司", icon: "yinhangka" },
},
{
path: "collectionAdd",
component: () => import("@/views/collection/collectionAdd"),
name: "collectionAdd",
hidden: true,
meta: { title: "新增收款银行", icon: "yinhangka" },
},
{
path: "collectionInfo",
component: () => import("@/views/collection/collectionInfo"),
name: "collectionInfo",
hidden: true,
meta: { title: "收款公司详情", icon: "yinhangka" },
},
],
},]
//最后可以获取为 这样子
let newList = [{
path: "/custom",
name: "custom",
redirect: "customManage",
meta: { title: "客户管理", icon: "kehu" },
alwaysShow: true,
children: [
{
path: "customManage",
component: () => import("@/views/custom/customManage"),
name: "customManage",
meta: { title: "客户管理", icon: "kehu" },
},
{
path: "customManage/add",
component: () => import("@/views/custom/customComponent/add.vue"),
name: "customManageAdd",
hidden: true,
meta: { title: "新增客户", icon: "" },
},]
},
{
path: "/collection",
name: "collection",
redirect: "collectionNumber",
meta: { title: "收款公司", icon: "yinhangka" },
alwaysShow: true,
children: [
{
path: "collectionNumber",
component: () => import("@/views/collection/collectionNumber"),
name: "collectionNumber",
meta: { title: "收款公司", icon: "yinhangka" },
},]
}]
求求了