在一个后台管理的项目中,关于路由的配置,
    我们需要实现的一个布局是header,aside,main三部分,后期还可能添加footer部分,实现的需求是请求数据时,局部的刷新,这个时候我们就需要对路由进行配置。要实现main部分的局部刷新,还要考虑404页面
直接上代码
import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router);
const _import_ = file = > () = > import('../pages/' + file + '.vue');
const asyncRouterMap = [];
const constantRouterMap = [
{
path: '/login',
name: 'Login',
component: _import_('Login/index'),
meta: {
title: "登 录",
auth: false
},
},
{
path: '/',
name: 'Home',
component: _import_('Home'),
redirect: {
name: 'Index'
},
children: [
{
path: 'index',
name: 'Index',
component: _import_('Index/index'),
meta: {
title: "工作台",
auth: true,
crumbs: [{
name: '概况'
}, {
name: '工作台'
}]
}
},
{
path: 'register',
name: 'Register',
component: _import_('Register/index'),
meta: {
title: "挂号记录",
auth: true,
crumbs: [{
name: '就诊管理'
}, {
name: '挂号记录'
}]
}
},
{
path: 'register/refundmoney',
name: 'RefundMoney',
component: _import_('Register/RefundMoney/index'),
meta: {
title: "挂号详情",
auth: true,
crumbs: [{
name: '就诊管理'
}, {
name: '挂号记录'
}]
},
},
{
path: 'doctor',
name: 'doctor',
component: _import_('Doctor/index'),
meta: {
title: "医生列表",
auth: true,
crumbs: [{
name: '医生管理'
}, {
name: '医生管理'
}]
},
},
{
path: 'doctor/supervise',
name: 'DoctorSupervise',
component: _import_('Doctor/supervise/index'),
meta: {
title: "医生信息",
auth: true,
crumbs: [{
name: '医生管理'
}, {
name: '医生管理'
}]
},
},
{
path: 'doctor/editdoctor',
name: 'EditDoctor',
component: _import_('Doctor/edidoctor/editdoctor'),
meta: {
title: "编辑医生信息",
auth: true,
crumbs: [{
name: '医生管理'
}, {
name: '医生管理'
}]
},
},
{
path: 'doctor/scheduling',
name: 'doctorScheduling',
component: _import_('Doctor/scheduling/index'),
meta: {
title: "修改医生排班",
auth: true,
crumbs: [{
name: '医生管理'
}, {
name: '排班管理'
}]
},
},
{
path: 'depart',
name: 'depart',
component: _import_('Department/index'),
meta: {
title: "科室管理列表",
auth: true,
crumbs: [{
name: '医院管理'
}, {
name: '科室管理'
}]
},
},
{
path: 'depart/edit',
name: 'DepartEdit',
component: _import_('Department/Edit/index'),
meta: {
title: "编辑科室信息",
auth: true,
crumbs: [{
name: '医院管理'
}, {
name: '科室管理'
}]
},
},
{
path: 'patient',
name: 'Patient',
component: _import_('Patient/index'),
meta: {
title: "就诊人管理",
auth: true,
crumbs: [{
name: '就诊人管理'
}, {
name: '就诊人管理'
}]
},
},
{
path: 'patient/info',
name: 'Info',
component: _import_('Patient/Info/index'),
meta: {
title: "就诊人信息",
auth: true,
crumbs: [{
name: '就诊人管理'
}, {
name: '就诊人管理'
}]
},
},
{
path: 'scheduling',
name: 'Scheduling',
component: _import_('Scheduling/index'),
meta: {
title: "排班列表",
auth: true,
crumbs: [{
name: '医生管理'
}, {
name: '排班管理'
}]
},
},
{
path: 'scheduling/edit',
name: 'SchedulingEdit',
component: _import_('Scheduling/Edit/index'),
meta: {
title: "排班编辑",
auth: true,
crumbs: [{
name: '医生管理'
}, {
name: '排班管理'
}]
},
},
{
path: 'service',
name: 'Service',
component: _import_('Service/index'),
meta: {
title: "服务管理",
auth: true,
crumbs: [{
name: '医院管理'
}, {
name: '服务管理'
}]
},
},
{
path: 'service/edit',
name: 'ServiceEdit',
component: _import_('Service/Edit/index'),
meta: {
title: "编辑服务",
auth: true,
crumbs: [{
name: '医院管理'
}, {
name: '服务管理'
}]
},
}
]
},
{
path: '/404',
name: '404',
component: _import_('Error/index'),
meta: {
title: "请求页面未找到",
auth: false
},
},
{
path: '*',
meta: {
title: "请求页面未找到",
auth: false
},
redirect: '/404'
}
];
const router = new Router({
mode: 'hash',
base: process.env.BASE_URL,
routes: constantRouterMap,
linkActiveClass: "router-link-active",
});
export default router
路由配置的顺序对路由的加载也是有很大的影响,我们后台管理系统,需要先进行登录处理,然后会默认访问首页,当然,我们也要考虑到404页面,404页面包括哪些呢?
我对404的理解就是在路由的映射列表中,没有找到对应的路由从而返回404;
这里,我们可以采用”*”通配符来进行匹配,当然顺序也是要注意的,login。首页 》children。    404。   “*”
当然我们还需要进行路由守卫的设置,我们可以单独的放在permission.js文件中 

vue-route(三)后台管理路由配置的更多相关文章

  1. vue中实现后台管理路由标签页

    <template> <section> <div class="navTabList el-tabs__nav-scroll" id="t ...

  2. 写了一个vue+antdv的后台管理模板

    1,项目简介 写在前面===>这是一个vue+antdv的后台管理模板 项目地址: https://github.com/BaiFangZi/vue-antd-manage 1.1,概述 ​ 最 ...

  3. vue+elementui搭建后台管理界面(5递归生成侧栏路由)

    有一个菜单树,顶层菜单下面有多个子菜单,子菜单下还有子菜单... 这时候就要用递归处理 1 定义多级菜单 修改 src/router/index.js 的 / 路由 { path: '/', redi ...

  4. Solr后台管理界面配置

    配置来源 https://stackoverflow.com/questions/28043957/how-to-set-apache-solr-admin-password 注意:配置用户名密码后 ...

  5. vue新建项目之标准路由配置--父子嵌套界面

    配置路由所有用到的地方总共四步或者说四处 1.index.js(src--router--index.js) 父子界面嵌套---需要配置子路由 import Vue from 'vue' import ...

  6. vue+elementui搭建后台管理界面(7 vuex和mockjs的使用)

    将权限管理应用到系统,首先做好登录, 点击登录按钮后,触发以下动作 vuex 中的 login 动作,设置 cookie vuex 中的 getuserinfo , 获取权限.用户名.头像等 由于目前 ...

  7. vue+elementui搭建后台管理界面(2首页)

    1 会话存储 使用html5的 sessionStorage 对象临时保存会话 // 保存会话 sessionStorage.setItem('user', username) // 删除会话 ses ...

  8. vue+elementui搭建后台管理界面

    1 会话存储 使用html5的 sessionStorage 对象临时保存会话 // 保存会话 sessionStorage.setItem('user', username) // 删除会话 ses ...

  9. Vue脚手架的搭建和路由配置

随机推荐

  1. Vmware 设置桥接模式

    在搭建VMware虚拟机的时候要配置网络 可以看到一共主要就3种 1.桥接模式(Bridge) 虚拟系统的IP可设置成与本机系统在同一网段,虚拟系统相当于网络内的一台.独立的机器,与本机共同插在一个H ...

  2. poj_2528 Mayor's posters (线段树经典题+离散化方法)

    由于题面中给定的wall最大长度为10 000 000:若简单用线段树势必会超时. 而注意到题面中规定了输入海报的个数<=1000:因此不妨离散化,使得线段中叶节点仅含有1000个,那么线段最大 ...

  3. 爬虫框架Scrapy之Item Pipeline

    Item Pipeline 当Item在Spider中被收集之后,它将会被传递到Item Pipeline,这些Item Pipeline组件按定义的顺序处理Item. 每个Item Pipeline ...

  4. MATLAB 图形图像处理

    theme: MATLAB author: pprp date: 2018/2/2 --- MATLAB 图形图像处理 二维绘图命令 plot 线性空间 plot(t,[x1,x2,x3]) : 在同 ...

  5. Java进阶之自动拆箱与自动装箱

    序. java基本类型介绍 java中,基本数据类型一共有8种,详细信息如下表: 类型 大小 范围 默认值 byte 8 -128 - 127 0 short 16 -32768 - 32768 0 ...

  6. rownum和order by的执行顺序问题

    SQL中rownum和order by的执行顺序的问题 : 在一个SQL中,如果同时使用rownum和order by,会有一个先后顺序的问题. 比如select id1,id2 from t_tab ...

  7. 机器学习笔记—混合高斯和 EM 算法

    本文介绍密度估计的 EM(Expectation-Maximization,期望最大). 假设有 {x(1),...,x(m)},因为是无监督学习算法,所以没有 y(i). 我们通过指定联合分布 p( ...

  8. UIAutomation学习入门

    一.界面的自动化操作 .Ui自动化测试 .软件外挂 二.Win32基础知识 a.Win32中一切元素皆窗口,窗口之间有父子关系.整个桌面是一个“根窗口”. b.进程: 根据进程id拿到进程对象Proc ...

  9. rest 学习总结(最近不间断更新)

    一.rest 简单介绍 1.http://www.zhihu.com/question/27785028 2.http://www.cnblogs.com/549294286/p/3524064.ht ...

  10. ACM比赛辅导--授课内容

    Lesson1(3月19日) 1.讲解Dev-C++.VC++6.0的单步调试方法 2.学习比赛的基本输入输出,练习C语言网的1085—1092 Lesson2(3月21日) 1.学习挑战程序设计,第 ...