在这里插入图片描述

<template>
    <aside class="menu">
        <el-scrollbar>
            <el-menu class="menu-main" router :default-active="route.path" unique-opened background-color="#18214C"
                text-color="#fff">
                <menuItem v-for="item in menuList" :item="item" :key="item.path" />
            </el-menu>
        </el-scrollbar>
    </aside>
</template> 
<script setup>
import menuItem from "./components/menuItem.vue"
import { useRoute } from "vue-router"
const route = useRoute()

const menuList = [
    {
        path: "/index",
        component: () => import("@/views/index.vue"),
        name: "index",
        meta: {
            title: "一级菜单"
        }
    },
    {
        path: "/level",
        name: "level",
        meta: {
            title: "多级菜单"
        },
        children: [
            {
                path: "/level/level-1",
                name: "level-1",
                meta: {
                    title: "多级菜单-1"
                },
                children: [
                    {
                        path: "/level/level-1/level-1-1",
                        component: () => import("@/views/level/level-1/level-1-1.vue"),
                        name: "level-1-1",
                        meta: {
                            title: "多级菜单-1"
                        }
                    }]
            },
            {
                path: "/level/level-2",
                component: () => import("@/views/level/level-2.vue"),
                name: "level-2",
                meta: {
                    title: "多级菜单-2"
                }
            }
        ]
    }
]


</script>
<style lang='scss' scoped>
.menu {
    height: 100vh;
    overflow: hidden;
    background-color: #18214C;

    &-main {
        border: none;
    }

    &-main:not(.el-menu--collapse) {
        width: 220px;
    }
}
</style>
<template>
    <template v-if="item.meta && !item.meta.hidden">
        <el-sub-menu :index="item.path" :key="item.path" v-if="item?.children?.length > 0">
            <template #title>
                <el-icon>
                    <Aim />
                </el-icon>
                <span>{{ item.meta.title }}</span>
            </template>
            <menuItem v-for="child in item.children" :item="child" :key="child.path" />
        </el-sub-menu>
        <el-menu-item v-else :index="item.path">
            <el-icon>
                <Aim />
            </el-icon>
            <template #title>{{ item.meta.title }}</template>
        </el-menu-item>
    </template>
</template>
<script setup name="menuItem">
import { Aim } from '@element-plus/icons-vue'
const props = defineProps({
    item: {
        type: Object,
        default: () => { },
    },
})
</script>
<style lang='scss' scoped>
.el-menu-item.is-active {
    color: #fff;
    background: #2260FF;
}
</style>
GitHub 加速计划 / vu / vue
207.54 K
33.66 K
下载
vuejs/vue: 是一个用于构建用户界面的 JavaScript 框架,具有简洁的语法和丰富的组件库,可以用于开发单页面应用程序和多页面应用程序。
最近提交(Master分支:2 个月前 )
73486cb5 * chore: fix link broken Signed-off-by: snoppy <michaleli@foxmail.com> * Update packages/template-compiler/README.md [skip ci] --------- Signed-off-by: snoppy <michaleli@foxmail.com> Co-authored-by: Eduardo San Martin Morote <posva@users.noreply.github.com> 4 个月前
e428d891 Updated Browser Compatibility reference. The previous currently returns HTTP 404. 5 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐