123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <template>
- <el-menu :default-active="active" v-bind="config" class="el-menu-vertical-demo" :collapse="isCollapse">
- <naf-menu-item @naf-menu-item="menuItem" v-for="(item, index) in menuItems" :key="index" :item="item" :index="item.path"></naf-menu-item>
- </el-menu>
- </template>
- <script>
- import nafMenuItem from './menu-item'
- const config = {
- backgroundColor: process.env.VUE_APP_MENU_BACKGROUNDCOLOR,
- textColor: process.env.VUE_APP_MENU_TEXTCOLOR,
- activeTextColor: process.env.VUE_APP_MENU_ACTIVETEXTCOLOR
- }
- export default {
- props: {
-
- isCollapse: { type: Boolean, default: false },
-
- menuItems: Array
- },
- components: {
- nafMenuItem
- },
- computed: {
-
- active () {
-
- if (this.$route.path === '/frame') return ''
-
- let active = ''
-
- const item = (path, items) => {
-
- items.filter(p => {
-
- if (`/frame${p.path}` === path) active = p.path
-
- if (p.children) item(path, p.children)
- })
- }
-
- const path = this.$route.path
-
- item(path, this.menuItems)
- return active
- }
- },
- data () {
- return {
- config
- }
- },
- methods: {
-
- menuItem (e) {
- const url = `/frame${e.path}`
- if (url === this.$route.path) return
- this.$router.push(url)
- }
- },
- mounted () {}
- }
- </script>
- <style lang="less" scoped>
- .el-menu-vertical-demo {
- height: 100%;
- }
- </style>
|