≡
  • 网络编程
  • 数据库
  • CMS技巧
  • 软件编程
  • PHP笔记
  • JavaScript
  • MySQL
位置:首页 > 网络编程 > vue.js

Vue 配合eiement动态路由,权限验证的方法

人气:434 时间:2019-04-12

这篇文章主要为大家详细介绍了Vue 配合eiement动态路由,权限验证的方法,具有一定的参考价值,可以用来参考一下。

感兴趣的小伙伴,下面一起跟随四海网的小编两巴掌来看看吧!

 

1.要实现动态路由,只需要在main.js中将所有路由表先规定好,如下

 

代码如下:


const routes=[
 {path:'/login',component:login},/*登录*/
 
 {path:'/home',component:home},/*首页*/
 {path:'/monitor',component:monitor},/*实时监控*/
 {path: "/orderQuery", component: orderQuery},/*电子围栏*/
 {path: "/fenceSet", component: fenceSet},/*电子围栏*/
 
 {path:'/orderCenter',component:orderCenter},/*订单中心*/
 {path:'/carctlExamine',component:carctlExamine},/*车管员审批*/
 {path:'/partExamine',component:partExamine},/*部门领导审批*/
 {path:'/vpExamine',component:vpExamine},/*副总审批*/
 
 {path:'/distribute',component:distribute},/*调度派单*/
 {path:'/receipt',component:receipt},/*回执*/
 
 {path:'/trajectory',component:trajectory},/*轨迹回放*/
 {path:'/statistics',component:statistics },/*统计*/
 
 {path:'/car',component:car},/*车辆管理*/
 {path:'/user',component:user},/*用户管理*/
 {path:'/equipment',component:equipment},/*设备管理*/
 {path:'/group',component:group},/*小组维护*/
 {path:'/driver',component:driver},/*驾驶员管理*/
 
 {path: '/company', component: company},/*公司管理*/
 {path: '/adminManage', component: adminManage},/*公司员管理*/
 {path: '/roleManage', component: roleManage},/*角色管理*/
 {path:'/systemDaily',component:systemDaily },/*系统日志*/
 
 
 
];

 

2.把前端路由表发给后台和后台协商返回的数据形式,在app.vue中,使用《el=menu》循环出来后台返回的路由表如下

 

代码如下:


 <el-menu
  :default-active="$route.path"
  class="el-menu-demo"
  mode="horizontal"
  @select="handleSelect"
  background-color="#545c64"
  text-color="#fff"
  active-text-color="#85ffca">
 
  <el-menu-item :index="item.path" v-for="item in pathList"
      v-if="item.path!=null" :key="item.id" >
  <router-link :to="item.path">{{item.name}}</router-link>
  </el-menu-item>/*一级导航*/
 
  <el-submenu v-if="item.path==null" :key="item.id":index="item.name" v-for="item in pathList">
  <template slot="title">{{item.name}}</template>
 
  <el-menu-item v-for="child in item.children" :index="child.path"
   :key="child.id" v-if="child.path!=null" >/*二级导航*/
   <router-link :to="child.path">{{child.name}}</router-link>
 
  </el-menu-item>
  <el-submenu v-if="child.children!=[]&&child.path==null" v-for="child in item.children":key="child.id":index="child.name" >
   <template slot="title">{{child.name}}</template>
   <el-menu-item v-for="three in child.children":index="three.path":key="three.id">/*若存在三级导航*/
   <router-link :to="three.path">{{three.name}}</router-link>
   </el-menu-item>
  </el-submenu>
 
  </el-submenu>
 
 </el-menu>

这样就可以在登录的时候根据接口获取到当前用户所拥有的权限以及路由表,这样动态路由就做好了 。我们是根据页面来确定权限的,没有页面就代表没有权限无法查看页面。

以上这篇Vue 配合eiement动态路由,权限验证的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持四海网。

本文来自:http://www.q1010.com/184/6091-0.html

注:关于Vue 配合eiement动态路由,权限验证的方法的内容就先介绍到这里,更多相关文章的可以留意四海网的其他信息。

关键词:vue.js

您可能感兴趣的文章

  • 基于vue v-for 多层循环嵌套获取行数的方法
  • VUE v-for循环中每个item节点动态绑定不同函数的实例
  • vue-router之nuxt动态路由设置的两种方法小结
  • 解决vue A对象赋值给B对象,修改B属性会影响到A的问题
  • 解决IE11 vue +webpack 项目中数据更新后页面没有刷新的问题
  • 分析Axios统一错误处理与后置
  • vue单页缓存存在的问题及解决方案(小结)
  • vue使用rem实现 移动端屏幕适配
  • vue如何进行动画的封装
  • Vue2.5学习笔记之如何在项目中使用和配置Vue
上一篇:vue 循环加载数据并获取第一条记录的方法
下一篇:vue-router之nuxt动态路由设置的两种方法小结
热门文章
  • Vue 报错TypeError: this.$set is not a function 的解决方法
  • vue实现动态添加数据滚动条自动滚动到底部的示例代码
  • vue项目设置scrollTop不起作用(总结)
  • vue项目中使用vue-i18n报错的解决方法
  • iview实现select tree树形下拉框的示例代码
  • 分析关于element级联选择器数据回显问题
  • vue项目打包后打开页面空白解决办法
  • 解决element ui select下拉框不回显数据问题的解决
  • element-ui table span-method(行合并)的实现代码
  • element-ui 设置菜单栏展开的方法
  • 最新文章
    • 理解vue ssr原理并自己搭建简单的ssr框架
    • vue favicon设置以及动态修改favicon的方法
    • vue-router启用history模式下的开发及非根目录部署方法
    • 从零开始在NPM上发布一个Vue组件的方法步骤
    • Element input树型下拉框的实现代码
    • Vue 报错TypeError: this.$set is not a function 的解决方法
    • Vue.js组件高级特性实例分析
    • 浅谈VueJS SSR 后端绘制内存泄漏的相关解决经验
    • 分析Vue.js自定义tipOnce指令用法实例
    • 浅谈vuex actions和mutation的异曲同工

四海网收集整理一些常用的php代码,JS代码,数据库mysql等技术文章。