实际前端项目路由配置

一 组件定义

1 创建vue组件

在src/views文件夹下创建以下文件夹和文件

2 form.vue

<template>
  <div class="app-container">
    <h1>讲师管理</h1>
    <p>讲师表单</p>
  </div>
</template>

3 list.vue

<template>
  <div class="app-container">
    <h1>讲师管理</h1>
    <p>讲师列表</p>
  </div>
</template>

二 路由定义

修改 src/router/index.js 文件,重新定义constantRouterMap

注意:每个路由的name不能相同

export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },


  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'Dashboard',
    hidden: true,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index')
    }]
  },


  // 讲师管理
  {
    path: '/teacher',
    component: Layout,
    redirect: '/teacher/list',
    name: 'Teacher',
    meta: { title: '讲师管理' },
    children: [
      {
        path: 'list',
        name: 'TeacherList',
        component: () => import('@/views/teacher/list'),
        meta: { title: '讲师列表' }
      },
      {
        path: 'create',
        name: 'TeacherCreate',
        component: () => import('@/views/teacher/form'),
        meta: { title: '添加讲师' }
      },
      {
        path: 'edit/:id',
        name: 'TeacherEdit',
        component: () => import('@/views/teacher/form'),
        meta: { title: '编辑讲师' },
        hidden: true
      }
    ]
  },


  { path: '*', redirect: '/404', hidden: true }
]

三 项目其他配置

1 项目名称

将 vue-admin-template-master 重命名为 guli_admin

2 端口号

在 config/index.js中修改

port: 9528,

3 国际化设置

src/main.js,第7行,修改语言为 zh-CN,使用中文语言环境,例如:日期时间组件

import locale from 'element-ui/lib/locale/lang/zh-CN' // lang i18n

4 入口页面

index.html

<title>谷粒学院后台管理系统</title>

5 登录页

src/views/login/index.vue,第4行

<h3 class="title">谷粒学院后台管理系统</h3>

四 测试

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值