一个基于Vue3和ElementPlus的后台管理布局

简介: 一个基于Vue3和ElementPlus的后台管理布局

在App.vue的文件可以直接粘贴使用,注意:在此之前要删除vue脚手架自带的CSS全局样式文件,vue3图标的使用在main.js文件中进行全局注册。

<template>
    <div class="layout">
        <el-container  class="container">
            <el-aside class="aside">
                <div class="head">
                    <div>
                        <img src="//s.weituibao.com/1582958061265/mlogo.png" alt="logo">
                        <span>vue3</span>
                    </div>
                </div>
                <div class="line" />
                <el-menu
                        background-color="#222832"
                        text-color="#fff"
                        :router="true"
                >
                    <el-menu-item index="/introduce"><el-icon><House /></el-icon>首页</el-menu-item>
                    <el-sub-menu index="1">
                        <template #title>
                            <span>模块信息管理</span>
                        </template>
                        <el-menu-item-group>
                            <el-menu-item index="/dashboard"><el-icon><Odometer /></el-icon>模块信息管理</el-menu-item>
                        </el-menu-item-group>
                    </el-sub-menu>
                </el-menu>
            </el-aside>
            <el-container class="content">
                <div class="header">
                    <div class="left">
                    </div>
                    <div class="right">
                        <el-popover
                                placement="bottom"
                                :width="320"
                                trigger="click"
                                popper-class="popper-user-box"
                        >
                            <template #reference>
                                <div class="author">
                                    <el-icon><Avatar /></el-icon>
                                     admin
                                </div>
                            </template>
                            <div class="nickname">
                                <p>登录名:admin </p>
                                <el-tag size="small" effect="dark" class="logout" @click="logout">退出</el-tag>
                            </div>
                        </el-popover>
                    </div>
                </div>
                <div class="main">
                    <router-view />
                </div>
                <div class="footer">
                    <div class="left">底部栏</div>
                    <div class="right">
                        <a target="_blank" href="https://github.com/newbee-ltd/vue3-admin">vue3-shop</a>
                    </div>
                </div>
            </el-container>
        </el-container>
    </div>
</template>
<script setup>
</script>
<style scoped>
    .layout {
        min-height: 100vh;
        background-color: #ffffff;
    }
    .container {
        height: 100vh;
    }
    .aside {
        width: 200px!important;
        background-color: #222832;
    }
    .head {
        display: flex;
        align-items: center;
        justify-content: center;
        height: 50px;
    }
    .head > div {
        display: flex;
        align-items: center;
    }
    .head img {
        width: 50px;
        height: 50px;
        margin-right: 10px;
    }
    .head span {
        font-size: 20px;
        color: #ffffff;
    }
    .line {
        border-top: 1px solid hsla(0,0%,100%,.05);
        border-bottom: 1px solid rgba(0,0,0,.2);
    }
    .content {
        display: flex;
        flex-direction: column;
        max-height: 100vh;
        overflow: hidden;
    }
    .main {
        height: calc(100vh - 100px);
        overflow: auto;
        padding: 10px;
    }
</style>
<style>
    body {
        padding: 0;
        margin: 0;
        box-sizing: border-box;
    }
    .el-menu {
        border-right: none!important;
    }
    .el-submenu {
        border-top: 1px solid hsla(0, 0%, 100%, .05);
        border-bottom: 1px solid rgba(0, 0, 0, .2);
    }
    .el-submenu:first-child {
        border-top: none;
    }
    .el-submenu [class^="el-icon-"] {
        vertical-align: -1px!important;
    }
    a {
        color: #409eff;
        text-decoration: none;
    }
    .el-pagination {
        text-align: center;
        margin-top: 20px;
    }
    .el-popper__arrow {
        display: none;
    }
    .footer {
        height: 50px;
        border-top: 1px solid #e9e9e9;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0 20px;
    }
</style>
<style scoped>
    .header {
        height: 50px;
        border-bottom: 1px solid #e9e9e9;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0 20px;
    }
    .header .left .back {
        border: 1px solid #e9e9e9;
        padding: 5px;
        border-radius: 50%;
        margin-right: 5px;
        cursor: pointer;
    }
    .right > div > .icon{
        font-size: 18px;
        margin-right: 6px;
    }
    .author {
        margin-left: 10px;
        cursor: pointer;
    }
</style>
<style>
    .popper-user-box {
        background: url('https://s.yezgea02.com/lingling-h5/static/account-banner-bg.png') 50% 50% no-repeat!important;
        background-size: cover!important;
        border-radius: 0!important;
    }
    .popper-user-box .nickname {
        position: relative;
        color: #ffffff;
    }
    .popper-user-box .nickname .logout {
        position: absolute;
        right: 0;
        top: 0;
        cursor: pointer;
    }
</style>

图片展示如下:

8627103f7ee57bd619aa303728977dd8.png

相关文章
|
JavaScript 前端开发 安全
Vue 3
Vue 3以组合式API、Proxy响应式系统和全面TypeScript支持,重构前端开发范式。性能优化与生态协同并进,兼顾易用性与工程化,引领Web开发迈向高效、可维护的新纪元。(238字)
1589 139
|
缓存 JavaScript 算法
Vue 3性能优化
Vue 3 通过 Proxy 和编译优化提升性能,但仍需遵循最佳实践。合理使用 v-if、key、computed,避免深度监听,利用懒加载与虚拟列表,结合打包优化,方可充分发挥其性能优势。(239字)
830 1
|
开发工具 iOS开发 MacOS
基于Vite7.1+Vue3+Pinia3+ArcoDesign网页版webos后台模板
最新版研发vite7+vue3.5+pinia3+arco-design仿macos/windows风格网页版OS系统Vite-Vue3-WebOS。
1444 11
|
JavaScript 安全
vue3使用ts传参教程
Vue 3结合TypeScript实现组件传参,提升类型安全与开发效率。涵盖Props、Emits、v-model双向绑定及useAttrs透传属性,建议明确声明类型,保障代码质量。
922 0
|
缓存 前端开发 大数据
虚拟列表在Vue3中的具体应用场景有哪些?
虚拟列表在 Vue3 中通过仅渲染可视区域内容,显著提升大数据列表性能,适用于 ERP 表格、聊天界面、社交媒体、阅读器、日历及树形结构等场景,结合 `vue-virtual-scroller` 等工具可实现高效滚动与交互体验。
1425 1
|
缓存 JavaScript UED
除了循环引用,Vue3还有哪些常见的性能优化技巧?
除了循环引用,Vue3还有哪些常见的性能优化技巧?
785 0
|
JavaScript
vue3循环引用自已实现
当渲染大量数据列表时,使用虚拟列表只渲染可视区域的内容,显著减少 DOM 节点数量。
545 0
|
JavaScript
Vue中如何实现兄弟组件之间的通信
在Vue中,兄弟组件可通过父组件中转、事件总线、Vuex/Pinia或provide/inject实现通信。小型项目推荐父组件中转或事件总线,大型项目建议使用Pinia等状态管理工具,确保数据流清晰可控,避免内存泄漏。
1061 2
|
缓存 JavaScript
vue中的keep-alive问题(2)
vue中的keep-alive问题(2)
931 137
|
人工智能 JavaScript 算法
Vue 中 key 属性的深入解析:改变 key 导致组件销毁与重建
Vue 中 key 属性的深入解析:改变 key 导致组件销毁与重建
2236 0