系统网站首页三种常见布局vue+elementui

  1. 左中右菜单布局
    <template><el-container><el-menu  class="el-menu-vertical-demo" style="width: 80px; height: 100vh;"background-color="#545c64"text-color="#fff"active-text-color="#ffd04b"@select="handleSelect" @open="handleOpen" @close="handleClose" :collapse="isCollapse"><el-menu-item :index="item.path" :key="item.path" v-for="item in sidebarRouters" v-if="item.meta" ><i class="el-icon-menu"><div style="font-size: 14px"><y>{{ item.meta.title.substring(0, 2) }}</y></div></i></el-menu-item></el-menu><el-menu style="width: 200px; height: 100vh;"class="el-menu-vertical-demo"background-color="#545c64"text-color="#fff"routeractive-text-color="#ffd04b"><el-menu-item  :index="item.path" :key="item.path" v-for="(item , index) in menuChildArr"><i class="el-icon-menu"></i><span >{{item.name}}</span></el-menu-item></el-menu><div class="scroll-box"><el-main><router-view></router-view></el-main></div></el-container></template><style>
    .el-menu-vertical-demo:not(.el-menu--collapse) {width: 200px;min-height: 400px;
    }.scroll-box {width: 100%;height: 100vh; /* 占据屏幕高度的 50% */overflow-y: auto; /* 垂直滚动 */box-sizing: border-box;
    }</style><script>
    import store from "@/store";export default {data() {return {sidebarRouters: store.getters.sidebarRouters,countIndex: 0,menuChildMap:{},menuChildArr:  [{name: '用户管理',path: '/system/user'},{name: '角色管理',path: '/system/role'}],isCollapse: true};},methods: {handleOpen(key, keyPath) {},handleSelect(key, keyPath){console.log("AAAAAAA="+ keyPath);console.log(key, keyPath);this.countIndex++;this.menuChildArr=[];let sidebarRouters = this.sidebarRouters;for (let i = 0; i < sidebarRouters.length; i++) {let item = sidebarRouters[i];if (item.meta && item.path==keyPath) {let title = item.meta.title;let children = item.children;for (let j = 0; j < children.length; j++) {let child = children[j];console.log("PPPPP:"+item.path+'/'+child.path);this.menuChildArr.push({name:child.meta.title, path:item.path+'/'+child.path});}}}console.log(JSON.stringify(this.menuChildArr));},handleClose(key, keyPath) {console.log(key, keyPath);}}
    }
    </script>
    

  2. 左右菜单布局
    <template><el-container><el-header style="background-color:#545c64;color: #fff;height: 7vh;"><h1>TMS运输管理系统</h1></el-header><el-container><div class="menu-container"><el-menu:default-active="activeIndex2"class="custom-menu"mode="vertical"@select="handleSelect"background-color="#545c64"text-color="#fff"routeractive-text-color="#ffd04b"><el-submenu  style="background-color: #545c64;" :index="item.path" :key="item.path" v-for="item in sidebarRouters" v-if="item.meta"><template slot="title" style="background-color: #545c64;">{{ item.meta.title }}</template><el-menu-item   style="background-color: #545c64;" :key="child.path" :index="item.path+'/'+child.path" v-for="child in item.children" v-if="child.meta" >{{ child.meta.title }}</el-menu-item></el-submenu><!--<el-menu-item index="/bar" >消息中心</el-menu-item><el-menu-item index="/foo" >消息中心2</el-menu-item><el-menu-item index=""><a href="https://www.ele.me" target="_blank">订单管理</a></el-menu-item>--></el-menu></div><div class="scroll-box"><!-- 路由出口 --><!-- 路由匹配到的组件将渲染在这里 --><el-tagstyle="margin: 5px;":key="tag"v-for="(tag ,index) in dynamicTags"closable:disable-transitions="false":effect="tag.effect"@click="handleClick(tag)"@close="handleClose(tag)"><router-link :to="tag.path"> {{tag.name}} </router-link></el-tag><router-view></router-view></div></el-container></el-container></template><script>import {mapState} from "vuex";
    import store from '@/store'
    export default {name: 'Layout',data() {return {effectValue:'plain',dynamicTags: [{name:'首页',path:'/',effect:'plain'}],activeIndex2: '0',menuIndexName:{'/system/user':'用户管理', '/system/role':'角色管理',  '/system/menu':'菜单管理',  '/system/dept':'部门管理', '/system/dict':'字典管理', '/system/post':'岗位管理','/system/job':'任务管理', '/system/config':'参数管理', '/system/notice':'通知公告', '/system/logininfor':'登录日志', '/system/operlog':'操作日志'},sidebarRouters: store.getters.sidebarRouters};},methods: {handleSelect(key, keyPath) {//console.log(JSON.stringify(store.getters.sidebarRouters))console.log(key, keyPath);let menuIndexName1 = new Map();let sidebarRouters = this.sidebarRouters;console.log("PPPPPFull111:"+JSON.stringify(sidebarRouters));for (let i = 0; i < sidebarRouters.length; i++) {let item = sidebarRouters[i];if (item.meta) {let title = item.meta.title;let children = item.children;for (let j = 0; j < children.length; j++) {let child = children[j];let pathFull = item.path+'/'+child.path;let titleChild = child.meta.title;console.log("PPPPP:"+pathFull,titleChild);menuIndexName1.set(pathFull,titleChild); // ={item.path+'/'+child.path:child.meta.title};}}}console.log("PPPPPFull:"+JSON.stringify(menuIndexName1));//置灰其它菜单按钮tagthis.dynamicTags.forEach(item => {item.effect='plain';});//激活当前菜单按钮taglet menuName = menuIndexName1.get(keyPath[1]);let menuNameJson={name:menuName, path:keyPath[1],effect:'dark'};this.dynamicTags.push(menuNameJson);//this.$router.push({path: keyPath});},handleClose(tag) {this.dynamicTags.splice(this.dynamicTags.indexOf(tag), 1);//激活后一个按钮tagif(this.dynamicTags.length>1){let dynamicTagsCur = this.dynamicTags[this.dynamicTags.length-1];dynamicTagsCur.effect='dark';let returnUrl = dynamicTagsCur.path;//刷新路由//this.$router.replace(decodeURIComponent(returnUrl || '/'));this.$router.push({path: returnUrl,query: {...this.$route.query,timestamp: Date.now()}});}},handleClick(tag){//置灰其它菜单按钮tagthis.dynamicTags.forEach(item => {item.effect='plain';});//单击事件激活当前按钮tag.effect='dark';}}
    };</script><style scoped lang="scss">
    .el-tag + .el-tag {margin: 5px;
    }
    .menu-container {display: flex;width:  15vw;height: 93vh; /* 占据整个视口高度 */
    }.custom-menu {flex: 1;height: 100%; /* 高度自适应父容器 */
    }
    .scroll-box {width:  100%;height: 93vh; /* 占据屏幕高度的 50% */overflow-y: auto; /* 垂直滚动 */box-sizing: border-box;
    }</style>
    

  3. 上下菜单布局

 

<template><div id="app"><el-menu:default-active="activeIndex2"class="el-menu-demo"mode="horizontal"@select="handleSelect"background-color="#545c64"text-color="#fff"routeractive-text-color="#ffd04b"><el-submenu :index="item.path" :key="item.path" v-for="item in sidebarRouters" v-if="item.meta"><template slot="title" >{{ item.meta.title }}</template><el-menu-item  :key="child.path" :index="item.path+'/'+child.path" v-for="child in item.children" v-if="child.meta" >{{ child.meta.title }}</el-menu-item></el-submenu><!--<el-menu-item index="/bar" >消息中心</el-menu-item><el-menu-item index="/foo" >消息中心2</el-menu-item><el-menu-item index=""><a href="https://www.ele.me" target="_blank">订单管理</a></el-menu-item>--></el-menu><!-- 路由出口 --><!-- 路由匹配到的组件将渲染在这里 --><el-tag:key="tag"v-for="(tag ,index) in dynamicTags"closable:disable-transitions="false":effect="tag.effect"@click="handleClick(tag)"@close="handleClose(tag)"><router-link :to="tag.path"> {{tag.name}} </router-link></el-tag><router-view></router-view></div></template><script>import {mapState} from "vuex";
import store from '@/store'
export default {name: 'Layout',data() {return {effectValue:'plain',dynamicTags: [{name:'首页',path:'/',effect:'plain'}],activeIndex2: '0',menuIndexName:{'/system/user':'用户管理', '/system/role':'角色管理',  '/system/menu':'菜单管理',  '/system/dept':'部门管理', '/system/dict':'字典管理', '/system/post':'岗位管理','/system/job':'任务管理', '/system/config':'参数管理', '/system/notice':'通知公告', '/system/logininfor':'登录日志', '/system/operlog':'操作日志'},sidebarRouters: store.getters.sidebarRouters};},methods: {handleSelect(key, keyPath) {//console.log(JSON.stringify(store.getters.sidebarRouters))console.log(key, keyPath);let menuIndexName1 = new Map();let sidebarRouters = this.sidebarRouters;console.log("PPPPPFull111:"+JSON.stringify(sidebarRouters));for (let i = 0; i < sidebarRouters.length; i++) {let item = sidebarRouters[i];if (item.meta) {let title = item.meta.title;let children = item.children;for (let j = 0; j < children.length; j++) {let child = children[j];let pathFull = item.path+'/'+child.path;let titleChild = child.meta.title;console.log("PPPPP:"+pathFull,titleChild);menuIndexName1.set(pathFull,titleChild); // ={item.path+'/'+child.path:child.meta.title};}}}console.log("PPPPPFull:"+JSON.stringify(menuIndexName1));//置灰其它菜单按钮tagthis.dynamicTags.forEach(item => {item.effect='plain';});//激活当前菜单按钮taglet menuName = menuIndexName1.get(keyPath[1]);let menuNameJson={name:menuName, path:keyPath[1],effect:'dark'};this.dynamicTags.push(menuNameJson);//this.$router.push({path: keyPath});},handleClose(tag) {this.dynamicTags.splice(this.dynamicTags.indexOf(tag), 1);//激活后一个按钮tagif(this.dynamicTags.length>1){let dynamicTagsCur = this.dynamicTags[this.dynamicTags.length-1];dynamicTagsCur.effect='dark';let returnUrl = dynamicTagsCur.path;//刷新路由//this.$router.replace(decodeURIComponent(returnUrl || '/'));this.$router.push({path: returnUrl,query: {...this.$route.query,timestamp: Date.now()}});}},handleClick(tag){//置灰其它菜单按钮tagthis.dynamicTags.forEach(item => {item.effect='plain';});//单击事件激活当前按钮tag.effect='dark';}}
};</script><style scoped lang="scss">
.el-tag {margin: 5px;
}
</style>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.pswp.cn/pingmian/84377.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

复习Git命令、Git命令使用流程、VSCode+Git插件管理工程源码

目录 1 引言 2 直接整理一个常用的流程&#xff0c;而不是死记硬背各种命令 3 解决冲突的说明和理解 4 git fetch的说明和理解 5 真正开发不用Git命令&#xff0c;而是使用VSCode插件管理工程 1 引言 以前主要用svn&#xff0c;Git用的少&#xff0c;这次再复习一下Git命…

384_C++_unit是4字节大小,能存储32位(bit)bool操作,[7][48]这里用于计划表的时间节点内,二维数组中每一位代表一种AI功能的开关状态

前置了解 uint 并不是 C/C++ 标准中的 原生类型,但不同平台或框架可能有定义。通常: 1. uint 可能是 unsigned int 的别名 在某些代码库(如 Arduino、某些嵌入式系统、部分库的头文件)中,uint 可能被定义为:typedef unsigned int uint;此时,uint 的大小和 unsigned in…

css~word-break属性

CSS中如何强制换行“....................................”&#xff1f; 当盒子宽度能放下“...”元素时&#xff0c;正常展示如下&#xff1a; 当盒子宽度不够放“...”元素时&#xff0c;文本就会溢出&#xff0c;导致整个内容被截断&#xff1a; 如何才能让其正常展示而不…

【Algorithm】Union-Find简单介绍

文章目录 Union-Find1 基本概念1.1 Find(x) - 查询操作1.2 Union(x, y) - 合并操作 2 并查集的结构和优化2.1 数据结构设计2.2 两大优化策略&#xff08;关键&#xff09;2.2.1 路径压缩&#xff08;Path Compression&#xff09;2.2.2 按秩合并&#xff08;Union by Rank or S…

LeetCode 高频 SQL 50 题(基础版)之 【高级字符串函数 / 正则表达式 / 子句】· 上

题目&#xff1a;1667. 修复表中的名字 题解&#xff1a; select user_id, concat(upper(left(name,1)),lower(right(name,length(name)-1))) name from Users order by user_id题目&#xff1a;1527. 患某种疾病的患者 题解&#xff1a; select * from Patients where con…

Linux系统的CentOS7发行版安装MySQL80

文章目录 前言Linux命令行内的”应用商店”安装CentOS的安装软件的yum命令安装MySQL1. 配置yum仓库2. 使用yum安装MySQL3. 安装完成后&#xff0c;启动MySQL并配置开机自启动4. 检查MySQL的运行状态 MySQL的配置1. 获取MySQL的初始密码2. 登录MySQL数据库系统3. 修改root密码4.…

Java + Spring Boot项目枚举(Enum)目录建议

在Java Spring Boot项目中&#xff0c;枚举&#xff08;Enum&#xff09;的定义文件没有固定的强制目录&#xff0c;但通常遵循项目结构和最佳实践来组织代码。以下是常见的推荐位置&#xff1a; 1. 领域模型相关枚举 目录: domain/enums 或 model/enums 场景: 当枚举与业务模…

Vue 模板语句的数据来源

&#x1f9e9; Vue 模板语句的数据来源&#xff1a;全方位解析 Vue 模板&#xff08;<template> 部分&#xff09;中的表达式、指令绑定&#xff08;如 v-bind, v-on&#xff09;和插值&#xff08;{{ }}&#xff09;都在一个特定的作用域内求值。这个作用域由当前 组件…

全新AI驱动Workspace Security 套件发布!Fortinet 电子邮件安全产品矩阵升级

专注推动网络与安全融合的全球性综合网络安全解决方案供应商 Fortinet&#xff08;NASDAQ&#xff1a;FTNT&#xff09;&#xff0c;近日宣布发布新一代企业级邮件安全解决方案FortiMail Workspace Security 安全套件&#xff0c;全面增强旗下数据和生产力安全产品组合&#xf…

二十、【用户管理与权限 - 篇二】前端交互:实现用户管理界面

【用户管理与权限 - 篇二】前端交互:实现用户管理界面 前言准备工作第一部分:更新并确认前端 API 服务第二部分:添加用户管理页面的路由和侧边栏入口第三部分:实现用户列表页面第四部分:实现用户编辑对话框组件第五部分:全面测试总结前言 在上一篇《【用户管理与权限 - …

LeetCode --- 452周赛

题目列表 3566. 等积子集的划分方案 3567. 子矩阵的最小绝对差 3568. 清理教室的最少移动 3569. 分割数组后不同质数的最大数目 一、等积子集的划分方案 由于本题的数据范围不大&#xff0c;我们可以暴力枚举所有可能的划分方式&#xff0c;代码如下 // C class Solution { …

使用Python提取照片元数据:方法与实战指南

## 引言&#xff1a;元数据的重要性 照片元数据&#xff08;Metadata&#xff09;是嵌入在图像文件中的隐藏信息&#xff0c;记录了拍摄设备、时间、地理位置、光圈快门参数等关键数据。这些信息广泛应用于**数字取证**、**照片管理**、**地理标记分析**和**版权验证**等场景。…

使用docker在3台服务器上搭建基于redis 6.x的一主两从三台均是哨兵模式

一、环境及版本说明 如果服务器已经安装了docker,则忽略此步骤,如果没有安装,则可以按照一下方式安装: 1. 在线安装(有互联网环境): 请看我这篇文章 传送阵>> 点我查看 2. 离线安装(内网环境):请看我这篇文章 传送阵>> 点我查看 说明&#xff1a;假设每台服务器已…

阿里云ACP云计算备考笔记 (5)——弹性伸缩

目录 第一章 概述 第二章 弹性伸缩简介 1、弹性伸缩 2、垂直伸缩 3、优势 4、应用场景 ① 无规律的业务量波动 ② 有规律的业务量波动 ③ 无明显业务量波动 ④ 混合型业务 ⑤ 消息通知 ⑥ 生命周期挂钩 ⑦ 自定义方式 ⑧ 滚的升级 5、使用限制 第三章 主要定义 …

CANopen转Modbus TCP转换器助生产线智能化升级

在自动化工业控制领域&#xff0c;CANopen和Modbus TCP是两种广泛采用的通信协议。它们各自具有独特的特点和优势&#xff0c;但在某些应用场景中&#xff0c;需要设备能够同时支持这两种通信标准。这就需要一个能够实现开疆智能CANopen转Modbus TCP转换的网关KJ-TCPC-CANP设备…

C++图书管理

图书馆的书籍分类系统使用二进制标签管理&#xff0c;0 代表儿童读物&#xff0c;1 代表青少年书籍。管理员发现当前的书架排列中不允许出现青少年书籍之后连接儿童读物的情况&#xff08;即 10 子串&#xff09;。管理员每次可以交换任意两本书的位置。请计算让书架符合规定所…

汽车免拆诊断案例 | 2010款捷豹XFL车制动警告灯、DSC警告灯异常点亮

故障现象  一辆2010款捷豹XFL车&#xff0c;搭载3.0 L发动机&#xff0c;累计行驶里程约为35万km。车主反映&#xff0c;该车组合仪表上的制动警告灯、动态稳定控制系统&#xff08;DSC&#xff09;警告灯异常点亮&#xff08;图1&#xff09;&#xff0c;且提示“DSC NOT AV…

el-upload组件,上传文件失败,:on-error方法失效

el-upload组件方法失效 问题原因解决 问题 使用el-upload组件上传文件&#xff0c;有这么一个问题上传文件处理报错Excel、Word。org.apache.poi.openxml4j.exceptions.OLE2NotOfficeXmlFileException。 按上述&#xff0c;后端编写完代码&#xff0c;输出正常&#xff0c;但…

可视化图解算法50:最小的K个数

牛客网 面试笔试 TOP101 | LeetCode 面试题 17.14. 最小K个数 1. 题目 描述 给定一个长度为 n 的可能有重复值的数组&#xff0c;找出其中不去重的最小的 k 个数。例如数组元素是4,5,1,6,2,7,3,8这8个数字&#xff0c;则最小的4个数字是1,2,3,4(任意顺序皆可)。 数…

Ragflow配置注意项

在 .env文件中启用v.0.19.0版本&#xff0c;带emabedding models RAGFLOW_IMAGEinfiniflow/ragflow:v0.19.0 RAGFlow image tagImage size (GB)Has embedding models?Stable?v0.19.0≈9✔️Stable releasev0.19.0-slim≈2❌Stable releasenightly≈9✔️Unstable nightly b…