标签:res bfc hid length style exp show temp scrollbar
<template> <el-scrollbar wrapClass="scrollbar-wrapper"> <el-menu mode="vertical" :show-timeout="200" :default-active="$route.path" :collapse="isCollapse" background-color="#304156" text-color="#bfcbd9" active-text-color="#409EFF" > <sidebar-item v-for="route in permission_routers" :key="route.name" :item="route" :base-path="route.path"></sidebar-item> </el-menu> </el-scrollbar> </template> <script> import { mapGetters } from ‘vuex‘ import SidebarItem from ‘./SidebarItem‘ import routers from ‘@/router/index‘ /* Layout */ // import Layout from ‘@/pages/layout/Layout‘ export default { data() { return { permission_routers: undefined, tmpArr: [], apiArr: JSON.parse(localStorage.getItem(‘SET_ROUTERS‘)) } }, mounted() { // console.log(this.apiArr) this.loop(this.apiArr) // console.log(this.tmpArr) this.loopRoutes(routers.options.routes) this.permission_routers = routers.options.routes }, methods: { checkIsHidden: function(opt) { if (this.apiArr) { if (this.tmpArr.indexOf(opt) >= 0) { return false } else { return true } } }, loop: function(arr) { for (var i = 0; i < arr.length; i++) { this.tmpArr.push(arr[i].resName) if (arr[i].hasSubResource === true) { this.loop(arr[i].subResources) } } }, loopRoutes: function(arrRoutes) { var _this = this for (var i = 0; i < arrRoutes.length; i++) { // console.log(arrRoutes[i]) if (arrRoutes[i].name) { // 开启关闭权限 arrRoutes[i].hidden = _this.checkIsHidden(arrRoutes[i].meta.title) // arrRoutes[i].hidden = false if (arrRoutes[i].children) { _this.loopRoutes(arrRoutes[i].children) } } } } }, components: { SidebarItem }, computed: { ...mapGetters([ // ‘permission_routers‘, ‘sidebar‘ ]), isCollapse() { return !this.sidebar.opened } } } </script>
标签:res bfc hid length style exp show temp scrollbar
原文地址:https://www.cnblogs.com/suanmei/p/10049848.html