欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 财经 > 产业 > 侧边菜单的展开和折叠

侧边菜单的展开和折叠

2025/1/18 23:37:01 来源:https://blog.csdn.net/qq_58706693/article/details/142556624  浏览:    关键词:侧边菜单的展开和折叠

在这里插入图片描述
在这里插入图片描述

环境准备:Vue3+Element-UI Plus

<script setup>
import {ref} from "vue";// 是否折叠菜单,默认折叠
const isCollapse = ref(true)// 退出登录
function logout() {alert('退出')
}// 个人中心
function profile() {alert('个人中心')
}
</script><template><el-container><el-aside><el-scrollbar><el-menu:collapse="isCollapse"active-text-color="#ffd04b"background-color="#545c64"class="el-menu-vertical-demo"default-active="2"text-color="#fff"><el-sub-menu index="1"><template #title><el-icon><location/></el-icon><span>Navigator One</span></template><el-menu-item-group title="Group One"><el-menu-item index="1-1">item one</el-menu-item><el-menu-item index="1-2">item two</el-menu-item></el-menu-item-group><el-menu-item-group title="Group Two"><el-menu-item index="1-3">item three</el-menu-item></el-menu-item-group><el-sub-menu index="1-4"><template #title>item four</template><el-menu-item index="1-4-1">item one</el-menu-item></el-sub-menu></el-sub-menu><el-menu-item index="2"><el-icon><Menu/></el-icon><span>Navigator Two</span></el-menu-item><el-menu-item index="3" disabled><el-icon><document/></el-icon><span>Navigator Three</span></el-menu-item><el-menu-item index="4"><el-icon><setting/></el-icon><span>Navigator Four</span></el-menu-item></el-menu></el-scrollbar></el-aside><el-container style="height: 100vh;"><el-header><el-row align="middle" justify="space-between" style="height: 100%"><el-col :span="1" style="cursor: pointer"><el-icon v-show="isCollapse" @click="isCollapse=false"><Expand/></el-icon><el-icon v-show="!isCollapse" @click="isCollapse=true"><Fold/></el-icon></el-col><el-col :span="1"><el-dropdown><el-image class="avatar" src="/public/vite.svg"></el-image><template #dropdown><el-dropdown-menu><el-dropdown-item @click="profile">个人信息</el-dropdown-item><el-dropdown-item @click="logout" divided>退出</el-dropdown-item></el-dropdown-menu></template></el-dropdown></el-col></el-row></el-header><el-main></el-main></el-container></el-container>
</template><style scoped lang="scss">
.el-container {.el-aside {height: 100vh;width: auto;:deep(.el-scrollbar__view ){height: 100%;.el-menu {height: 100%;width: 100%;}}}.el-container {.el-header {background-color: #ffffff;.avatar {border-radius: 50%;cursor: pointer;}}.el-main {background-color: #efefef;}}
}
</style>

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com