vue后台管理系统最初搭建

该文章展示了如何在Vue项目中构建登录成功后的页面,设置data文件夹下的index.js文件来导出菜单数据。然后,详细配置了VueRouter,包括首页、关于页以及一系列的数据统计、资源管理、试题管理和课程资源管理等子页面。此外,文章还提到了在页面中引入并使用这些菜单数据的方法。
摘要由CSDN通过智能技术生成

1.建立登陆成功后的页面
2.建立data文件夹index.js文件

export const menu = [
    {
        name:"数据统计",
        path:"/index/DataStatistics"
    },
   
    {
        name:"资源管理",
        path:'',
        children:[
            {
                name:"资源类型",
                path: '/index/ResourceType',
            },
            {
                name:"资源列表",
                path: '/index/ResourceLst',
            },
            {
                name:"资源推荐",
                path: '/index/recommendation',
            },
            {
                name:"资源标签",
                path: '/index/recommentag',
            }
        ]
    },
    {
        name:"试题管理",
        path:'',
        children:[
            {
                name:"试题类型",
                path: '/index/test',
            },
            {
                name:"试题列表",
                path: '/index/Listtest',
            },
            {
                name:"试题评论",
                path: '/index/comment',
            },
        ]
    },
    {
        name:"课程资源管理",
        path:'',
        children:[
            {
                name:"课时类型管理",
                path: '/index/Courseresources',
            },
            {
                name:"课时列表管理",
                path: '/index/course_list',
            },
            {
                name:"课时详情管理",
                path: '/index/SessionDetails',
            },
        ]
    },
    {
        name:"用户管理",
        path:'',
        children:[
            {
                name:"用户列表管理",
                path: '/index/UserList',
            },
            {
                name:"留言列表管理",
                path: '/index/MessageList',
            },
         
        ]
    }
]

3.设置路由

import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'

Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        name: 'home',
        component: HomeView
    },
    {
        path: '/about',
        name: 'about',

        component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
    },
    {
        path: '/index',
        name: 'index',

        component: () => import(/* webpackChunkName: "about" */ '../views/index'),
        redirect: "/index/DataStatistics",
        children: [
            {
                path: '/index/DataStatistics',
                name: 'DataStatistics',

                component: () => import(/* webpackChunkName: "about" */ '../views/DataStatistics'),
            },
            {
                path: '/index/ResourceType',
                name: 'ResourceType',

                component: () => import(/* webpackChunkName: "about" */ '../views/ResourceType'),
            },
            {
                path: '/index/ResourceLst',
                name: 'ResourceLst',

                component: () => import(/* webpackChunkName: "about" */ '../views/ResourceLst'),
            },
            {
                path: '/index/recommendation',
                name: 'recommendation',

                component: () => import(/* webpackChunkName: "about" */ '../views/recommendation'),
            },
            {
                path: '/index/recommentag',
                name: 'recommentag',

                component: () => import(/* webpackChunkName: "about" */ '../views/recommentag'),
            },
            {
                path: '/index/test',
                name: 'test',

                component: () => import(/* webpackChunkName: "about" */ '../views/test'),
            },
            {
                path: '/index/Listtest',
                name: 'Listtest',

                component: () => import(/* webpackChunkName: "about" */ '../views/Listtest'),
            },
            {
                path: '/page1',
                name: 'page1',
                component: () => import(/* webpackChunkName: "about" */ '../components/page/page1'),
            },
            {
                path: '/page',
                name: 'page',
                component: () => import(/* webpackChunkName: "about" */ '../components/page/page.vue'),
            },
            {
                path: '/page2',
                name: 'page2',
                component: () => import(/* webpackChunkName: "about" */ '../components/page/page2'),
            },
            {
                path: '/index/comment',
                name: 'comment',
                component: () => import(/* webpackChunkName: "about" */ '../views/comment.vue'),
            },
            {
                path: '/index/Courseresources',
                name: 'Courseresources',
                component: () => import(/* webpackChunkName: "about" */ '../views/Courseresources.vue'),
            },
            {
                path: '/index/course_list',
                name: 'course_list',
                component: () => import(/* webpackChunkName: "about" */ '../views/course_list.vue'),
            },
            {
                path: '/index/SessionDetails',
                name: 'SessionDetails',
                component: () => import(/* webpackChunkName: "about" */ '../views/SessionDetails.vue'),
            },
            {
                path: '/index/UserList',
                name: 'UserList',
                component: () => import(/* webpackChunkName: "about" */ '../views/UserList.vue'),
            },
            {
                path: '/index/MessageList',
                name: 'MessageList',
                component: () => import(/* webpackChunkName: "about" */ '../views/MessageList.vue'),
            },
        
        ]
    }
]

const router = new VueRouter({
    routes
})

export default router

4.引入菜单

import { menu } from "../data/index";

5.在页面中使用

 <el-container>
      <el-aside width="200px">
        <el-col :span="12">
          <el-menu
            :default-active="$route.path"
            :router="true"
            class="el-menu-vertical-demo"
            @open="handleOpen"
            @close="handleClose"
            background-color="#545c64"
            text-color="#fff"
            active-text-color="#ffd04b"
          >
            <div v-for="(item, index) of menu_data" :key="index">
              <el-menu-item :index="item.path" v-if="!('children' in item)">
                <i class="el-icon-setting"></i>
                <span slot="title">{{ item.name }}</span>
              </el-menu-item>
              <el-submenu v-else :index="String(index)">
                <template slot="title">
                  <i class="el-icon-location"></i>
                  <span>{{ item.name }}</span>
                </template>
                <el-menu-item-group>
                  <el-menu-item
                    :index="item1.path"
                    v-for="(item1, index1) of item.children" :key="index1">
                   <i class="el-icon-document-remove"></i> {{ item1.name }}</el-menu-item
                  >
                </el-menu-item-group>
                <!-- <el-menu-item :index="item1.path" v-for="(item1, index1) of item.children"> 
                  <i class="el-icon-document-remove"></i> {{item1.name}}</el-menu-item> -->
              </el-submenu>
            </div>
          </el-menu>
        </el-col>
      </el-aside>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>

在这里插入代码片

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

蒜苔肉丝

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值