Skip to content
This repository has been archived by the owner on Jun 28, 2023. It is now read-only.

二级路由的组件如何加载? #36

Closed
happysmile12321-cocplug opened this issue Jan 15, 2021 · 1 comment
Closed

二级路由的组件如何加载? #36

happysmile12321-cocplug opened this issue Jan 15, 2021 · 1 comment

Comments

@happysmile12321-cocplug
//流量管理
flow: {
	path: '/flow',
	redirect: 'flow/flowGather',
	meta: {title: 'flow'},
	children: [
		//流量管理 - 流量采集
		{
			path: 'flowGather',
			name: 'flowGather',
			meta: {title: 'flowGather'},
			component: () => import('../views/ddos/flow/flowGather.vue'),
		},
		//流量管理 - 流量分析
		{
			path: 'flowAnalysis',
			name: 'flowAnalysis',
			meta: {title: 'flowAnalysis'},
			component: () => import('../views/ddos/flow/flowAnalysis.vue'),
		},
		//流量管理 - 流量限制 -- ipblock
		{
			path: 'flowRestriction/ipblock',
			name: 'ipblock',
			meta: {title: 'ip封锁'},
			component: () => import('../views/ddos/flow/flowrestriction/ipblock/ipblock.vue'),
		},
	]
},

tree命令输出如下:
.
├── flow
│   ├── flow.vue
│   ├── flowAnalysis.vue
│   ├── flowGather.vue
│   └── flowrestriction
│   └── ipblock
│   └── ipblock.vue
├── sniffeSettings
│   ├── config
│   │   └── tcpdump_config.vue
│   └── taskManager
│   └── tsm
│   └── tsm.vue
└── srm
└── srm.vue

@woai3c
Copy link
Owner

woai3c commented Jan 15, 2021

菜单栏数据:

// 左侧菜单栏数据
        menuItems: [
            {
                name: 'home', // 要跳转的路由名称 不是路径
                size: 18, // icon大小
                type: 'md-home', // icon类型
                text: '主页', // 文本内容
            },
            {
                name: 'other', // 要跳转的路由名称 不是路径
                size: 18, // icon大小
                type: 'ios-egg-outline', // icon类型
                text: '单独的路由', // 点击侧边栏跳到一个单独的路由页面,需要提前在 router.js 定义
            },
            {
                size: 18, // icon大小
                type: 'md-arrow-forward', // icon类型
                text: '外链',
                url: 'https://www.baidu.com',
                isExternal: true, // 外链 跳到一个外部的 URL 页面
            },
            {
                text: '二级菜单',
                type: 'ios-paper',
                children: [
                    {
                        type: 'ios-grid',
                        name: 't1',
                        text: '表格',
                        // hidden 属性 隐藏此菜单 可以通过在地址栏上输入对应的 URL 来显示页面
                        // hidden: true,
                    },
                    {
                        size: 18, // icon大小
                        type: 'md-arrow-forward', // icon类型
                        text: '外链',
                        url: 'https://www.baidu.com',
                        isExternal: true, // 外链 跳到一个外部的 URL 页面
                    },
                    {
                        text: '三级菜单',
                        type: 'ios-paper',
                        children: [
                            {
                                type: 'ios-notifications-outline',
                                name: 'msg',
                                text: '查看消息',
                            },
                            {
                                type: 'md-lock',
                                name: 'password',
                                text: '修改密码',
                            },
                            {
                                type: 'md-person',
                                name: 'userinfo',
                                text: '基本资料',
                            },
                            {
                                size: 18, // icon大小
                                type: 'md-arrow-forward', // icon类型
                                text: '外链',
                                url: 'https://www.baidu.com',
                                isExternal: true, // 外链 跳到一个外部的 URL 页面
                            },
                        ],
                    },
                ],
            },
        ],

菜单栏上的 name 属性就是你要匹配的路由。然后你需要提前写好路由映射表,在 router.js 文件有:

// 本地所有的页面 需要配合后台返回的数据生成页面
export const asyncRoutes = {
    home: {
        path: 'home',
        name: 'home',
        meta: { title: '主页' },
        component: () => import('../views/Home.vue'),
    },
    t1: {
        path: 't1',
        name: 't1',
        meta: { title: '表格' },
        component: () => import('../views/T1.vue'),
    },
    password: {
        path: 'password',
        name: 'password',
        meta: { title: '修改密码' },
        component: () => import('../views/Password.vue'),
    },
    msg: {
        path: 'msg',
        name: 'msg',
        meta: { title: '通知消息' },
        component: () => import('../views/Msg.vue'),
    },
    userinfo: {
        path: 'userinfo',
        name: 'userinfo',
        meta: { title: '用户信息' },
        component: () => import('../views/UserInfo.vue'),
    },
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants