1.1静态布局
<template>
<div class="layout_container">
<!-- 左侧导航 -->
<div class="layout_slider"></div>
<!-- 顶部导航 -->
<div class="layout_tabbar"></div>
<!-- 内容展示区 -->
<div class="layout_main"></div>
</div>
</template>
<!-- <script lang="ts"></script> -->
<style scoped lang="scss">
.layout_container {
width: 100%;
height: 100vh;
.layout_slider {
color: white;
width: $base-menu-width;
height: 100vh;
background: $base-menu-background;
transition: all 0.3s;
.scrollbar {
width: 100%;
height: calc(100vh - $base-menu-logo-height);
.el-menu {
border-right: none;
}
}
}
.layout_tabbar {
position: fixed;
width: calc(100% - $base-menu-width);
height: $base-tabbar-height;
top: 0px;
left: $base-menu-width;
transition: all 0.3s;
background-color: aqua;
&.fold {
width: calc(100vw - $base-menu-min-width);
left: $base-menu-min-width;
}
}
.layout_main {
position: absolute;
width: calc(100% - $base-menu-width);
height: calc(100vh - $base-tabbar-height);
left: $base-menu-width;
top: $base-tabbar-height;
padding: 20px;
overflow: auto;
transition: all 0.3s;
&.fold {
width: calc(100vw - $base-menu-min-width);
left: $base-menu-min-width;
}
}
}
</style>
//项目提供scss全局变量
// 左侧菜单宽度
//定义项目主题颜色
//左侧的菜单的宽度
$base-menu-width :260px;
//左侧菜单的背景颜色
$base-menu-background:#001529;
$base-menu-min-width :50px;
// 顶部导航的高度
$base-tabbar-height:50px;
//左侧菜单logo高度设置
$base-menu-logo-height:50px;
//左侧菜单logo右侧文字大小
$base-logo-title-fontSize:20px;
1.2动态logo和标题搭建
src下创建setting.ts
// 项目图标和标题
export default {
title: 'v3后台管理系统', //项目标题设置
logo: '../../../../../public/logo.png', //项目配置logo
logoHidden: true, //logo组件是否隐藏
}
<template>
<div class="logo" v-if="setting.logoHidden">
<img :src="setting.logo" alt="" />
<p>{
{ setting.title }}</p>
</div>
</template>
<script setup lang="ts">
import setting from '@/setting'
</script>
<style scoped lang="scss">
.logo {
width: 100%;
height: $base-menu-logo-height;
color: white;
display: flex;
align-items: center;
padding: 10px;
img {
width: 40px;
height: 40px;
}
p {
font-size: $base-logo-title-fontSize;
margin-left: 10px;
}
}
</style>
1.3左侧静态布局
<template>
<div class="layout_container">
<!-- 左侧导航 -->
<div class="layout_slider">
<Logo />
<!-- 展示菜单 -->
<!-- 滚动组件 -->
<el-scrollbar class="scrollbar">
<!-- 菜单组件-->
<el-menu background-color="#001529" text-color="white" active-text-color="yellowgreen">
<el-menu-item index="1">首页</el-menu-item>
<el-menu-item index="1">数据大屏</el-menu-item>
<el-sub-m