国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

Vue 配合eiement動態路由,權限驗證的方法

2024-05-06 15:29:28
字體:
來源:轉載
供稿:網友

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>

這樣就可以在登錄的時候根據接口獲取到當前用戶所擁有的權限以及路由表,這樣動態路由就做好了 。我們是根據頁面來確定權限的,沒有頁面就代表沒有權限無法查看頁面。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 通许县| 环江| 溆浦县| 神池县| 石泉县| 云阳县| 类乌齐县| 綦江县| 五寨县| 丹凤县| 蛟河市| 遂溪县| 浦县| 巴楚县| 伊吾县| 昭苏县| 蓬安县| 会同县| 南平市| 微山县| 屯留县| 云南省| 丰都县| 阿勒泰市| 花垣县| 宁化县| 福贡县| 犍为县| 巴青县| 黔西县| 霍州市| 元江| 河南省| 肥城市| 梧州市| 呼和浩特市| 光泽县| 清新县| 永善县| 威远县| 永兴县|