基于Vue Router和element-ui的LayOut

一、展示

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

二、代码

app.vue

<template><div id="app"><el-container style="border: 1px solid #eee; height: 100vh"><el-aside  v-bind:width="asideWidth" style="background-color: rgb(48, 65, 86);"><el-menu :router="true" class="el-menu-vertical-demo" style="width: 200px; border: none"@open="handleOpen"@close="handleClose"@select="handleSelect":collapse-transition="false":collapse="isCollapse"background-color="#304156"text-color="#fff"active-text-color="#ffd04b"><el-menu-item index="/"><i class="el-icon-s-home"></i><span slot="title">XXX系统</span></el-menu-item><el-submenu :index="item.path" v-for="(item,index) in menu"  v-if="item.children!=null"><template slot="title" v-if="item.component==='Layout' && item.children!=null"><i :class="item.meta.icon"></i><span slot="title">{{item.meta.title}}</span></template><el-menu-item-group v-if="item.children!=null"><el-menu-item :index="c.component" v-for="(c,i) in item.children"v-if="c.component!=='ParentView'"><i :class="c.meta.icon"></i>{{c.meta.title}}</el-menu-item></el-menu-item-group><el-submenu :index="p.path" v-for="(p,i) in item.children" v-if="p.component==='ParentView'"><span slot="title">{{p.meta.title}}</span><el-menu-item :index="c.component" v-for="(c,i) in p.children">{{c.meta.title}}</el-menu-item></el-submenu></el-submenu><el-menu-item :index="item.path" v-for="(item,index) in menu" v-if="item.children==null"><i :class="item.meta.icon"></i><span slot="title">{{item.meta.title}}</span></el-menu-item></el-menu></el-aside><el-container><el-header style="font-size: 12px;background-color:#FFFFFF; padding: 0;height: auto"><el-row style="-webkit-box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08); box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08); "><el-col :xs="1" :sm="1" :md="1" :lg="1" :xl="1" style="text-align: left;"><span v-on:click="launch"><i style="font-size: 25px;line-height: 60px":class="launchIcon"></i></span></el-col><el-col :xs="19" :sm="19" :md="19" :lg="18" :xl="19"><el-breadcrumb separator="/" style="line-height: 60px;"><el-breadcrumb-item v-for="(item,index) in thisBreadcrumb"><a :href="item.path">{{item.title}}</a></el-breadcrumb-item></el-breadcrumb></el-col><el-col :xs="4" :sm="4" :md="4" :lg="4" :xl="4" style="text-align: right;"><span>王小虎</span><el-dropdown><i class="el-icon-setting" style="margin-left: 15px"></i><el-dropdown-menu slot="dropdown"><el-dropdown-item>查看</el-dropdown-item><el-dropdown-item>新增</el-dropdown-item><el-dropdown-item>删除</el-dropdown-item></el-dropdown-menu></el-dropdown></el-col></el-row><el-row style="padding: 3px 0;border-bottom: 1px solid #d8dce5;-webkit-box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.12), 0 0 3px 0 rgba(0, 0, 0, 0.04);box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.12), 0 0 3px 0 rgba(0, 0, 0, 0.04);"><div style="line-height: 0"><el-tag style="border-radius: 0;margin-left: 10px;"key="1"closable:disable-transitions="true"type=""effect="dark"@close="handleCloseTag(1)">首页</el-tag><el-tag style="margin-left: 15px;border-radius: 0;"key="2"closable:disable-transitions="true"type="info"@close="handleCloseTag(2)">关于</el-tag></div></el-row></el-header><el-main><router-view/></el-main></el-container></el-container></div>
</template><style>.el-header {background-color: #B3C0D1;color: #333;line-height: 60px;}.el-aside {color: #333;}a {color: #FFFFFF;text-decoration: none}body{padding: 0;margin: 0;}
</style><script>export default {data() {//这个对象一般从后端获取,菜单会存在数据库,动态获取const menuObj = [{"name": "System","path": "/system","hidden": false,"redirect": "noRedirect","component": "Layout","alwaysShow": true,"meta": {"title": "系统管理","icon": "el-icon-s-tools","noCache": false,"link": null},"children": [{"name": "User","path": "user","hidden": false,"component": "system/user/index","meta": {"title": "用户管理","icon": "el-icon-s-check","noCache": false,"link": null}},{"name": "Role","path": "role","hidden": false,"component": "system/role/index","meta": {"title": "角色管理","icon": "peoples","noCache": false,"link": null}},{"name": "Menu","path": "menu","hidden": false,"component": "system/menu/index","meta": {"title": "菜单管理","icon": "tree-table","noCache": false,"link": null}},{"name": "Dept","path": "dept","hidden": false,"component": "system/dept/index","meta": {"title": "部门管理","icon": "tree","noCache": false,"link": null}},{"name": "Post","path": "post","hidden": false,"component": "system/post/index","meta": {"title": "岗位管理","icon": "post","noCache": false,"link": null}},{"name": "Dict","path": "dict","hidden": false,"component": "system/dict/index","meta": {"title": "字典管理","icon": "dict","noCache": false,"link": null}},{"name": "Config","path": "config","hidden": false,"component": "system/config/index","meta": {"title": "参数设置","icon": "edit","noCache": false,"link": null}},{"name": "Notice","path": "notice","hidden": false,"component": "system/notice/index","meta": {"title": "通知公告","icon": "message","noCache": false,"link": null}},{"name": "Log","path": "log","hidden": false,"redirect": "noRedirect","component": "ParentView","alwaysShow": true,"meta": {"title": "日志管理","icon": "log","noCache": false,"link": null},"children": [{"name": "Operlog","path": "operlog","hidden": false,"component": "monitor/operlog/index","meta": {"title": "操作日志","icon": "form","noCache": false,"link": null}},{"name": "Logininfor","path": "logininfor","hidden": false,"component": "monitor/logininfor/index","meta": {"title": "登录日志","icon": "logininfor","noCache": false,"link": null}}]}]},{"name": "Http://ruoyi.vip","path": "/about","hidden": false,"component": "Layout","meta": {"title": "关于","icon": "el-icon-question","noCache": false,"link": "http://ruoyi.vip"}}]return {pathMap: {},thisBreadcrumb: [{"path": "/", "title": "首页"}],menu: menuObj,isCollapse: false,asideWidth: '200px',launchIcon: 'el-icon-s-fold'}},methods: {handleOpen(key, keyPath) {// console.log(key, keyPath);},handleClose(key, keyPath) {// console.log(key, keyPath);},handleSelect(key, keyPath) {// console.log(key, keyPath);this.thisBreadcrumb =[{"path": "/", "title": "首页"}]if (keyPath.length > 0) {const f = keyPath[0]const e = keyPath[keyPath.length - 1]// console.log(this.pathMap.get(f).get(e))const paths = this.pathMap.get(f).get(e)paths.forEach((path => {let item = {}item.path = '/'item.title = paththis.thisBreadcrumb.push(item)}))}},//展开左侧导航launch() {if (this.isCollapse) {//展开this.isCollapse = false;this.asideWidth = '200px'this.launchIcon = 'el-icon-s-fold'} else {//收起this.isCollapse = true;this.asideWidth = '64px'this.launchIcon = 'el-icon-s-unfold'}},handleCloseTag(tag) {console.log(tag)},filterMenuPaths(menu, map, fatherPaths) {//有children// console.log("e->" + fatherPaths)// if (menu.component==='Layout'){//// }let paths = []if (menu.children != null && menu.children.length >= 1) {menu.children.forEach((el) => {let fatherNow = [];fatherNow = fatherNow.concat(fatherPaths)fatherNow.push(menu.meta.title)this.filterMenuPaths(el, map, fatherNow)})} else { //没有有childrenpaths = paths.concat(fatherPaths)paths.push(menu.meta.title)map.set(menu.component, paths)}}},created: function () {this.pathMap = new Map();this.menu.forEach((m, index) => {let map = new Map();this.filterMenuPaths(m, map, [])this.pathMap.set(m.path, map)})}};
</script>

router

import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'Vue.use(VueRouter)const routes = [{path: '/',name: 'home',//组件自己创建component: HomeView},{path: '/about',name: 'about',// route level code-splitting// this generates a separate chunk (about.[hash].js) for this route// which is lazy-loaded when the route is visited.component: function () {//视图自己创建return import(/* webpackChunkName: "about" */ '../views/AboutView.vue')}}
]const router = new VueRouter({routes
})export default router

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

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

相关文章

前端高频算法

分析算法排序&#xff1a; 时间复杂度: 一个算法执行所耗费的时间。 空间复杂度: 运行完一个程序所需内存的大小。 执行效率、内存消耗、稳定性 三方面入手。 1. 排序 1.1 冒泡排序 冒泡的过程只涉及相邻数据的交换操作&#xff0c;所以它的空间复杂度为 O(1)。 为了保证…

政安晨:【Keras机器学习示例演绎】(二十八)—— 使用 卷积神经网络与循环神经网络 架构进行视频分类

目录 数据收集 设置 定义超参数 数据准备 序列模型 推论 政安晨的个人主页&#xff1a;政安晨 欢迎 &#x1f44d;点赞✍评论⭐收藏 收录专栏: TensorFlow与Keras机器学习实战 希望政安晨的博客能够对您有所裨益&#xff0c;如有不足之处&#xff0c;欢迎在评论区提出指正…

AIGC笔记--Diffuser的基本使用

目录 1--加载模型 2--半精度推理 3--固定随机种子 4--更改扩散步数 5--设置negative_prompt 1--加载模型 以下代码使用 from_pretrained() 来加载预训练模型&#xff0c;使用参数cache_dir来指定下载模型的存储地址&#xff1b; from diffusers import DiffusionPipeline,…

分享自己一篇在亚马逊云科技AWS官网发的Blog技术文章

小李哥在亚马逊AWS官网&#xff0c;作为第一作者发了自己的第一篇AWS Blog文章&#xff0c;也是自己今年在AWS官网的第11篇文章。文章主要内容是描述为出海的金融企业&#xff0c;搭建满足PCI-DSS合规、FIPS 140-2 Level 3安全标准的传输中数据加密云端方案&#xff0c;主要用于…

江苏省建设工程专业技术资格条件

江苏省建设工程专业技术资格条件评审文件链接江苏省人力资源和社会保障厅 人才人事 省专业技术人员职称&#xff08;职业资格&#xff09;工作领导小组 关于印发《江苏省建设工程专业技术资格条件&#xff08;试行&#xff09;》的通知评审工作的通知江苏省人力资源和社会保障厅…

【补充】1-auth的使用、扩写auth的user表、django支持缓存

1 Auth的使用 1.1 扩写auth的user表 2 缓存 1 Auth的使用 # django 的一个app---》用户的登录&#xff0c;退出&#xff0c;注册。。。# 配置文件中配置&#xff1a;---》表会被迁移INSTALLED_APPS [django.contrib.auth,]# auth有哪些表---权限控制&#xff1a;-Permission&a…

更深层次理解传输层两协议【UDP | TCP】【UDP 缓冲区 | TCP 8种策略 | 三次握手四次挥手】

博客主页&#xff1a;花果山~程序猿-CSDN博客 文章分栏&#xff1a;Linux_花果山~程序猿的博客-CSDN博客 关注我一起学习&#xff0c;一起进步&#xff0c;一起探索编程的无限可能吧&#xff01;让我们一起努力&#xff0c;一起成长&#xff01; 目录 再谈端口号 端口号的返回…

ML system 入坑指南

ML system 入坑指南 | 摸黑干活 最近ChatGpt大火,越来越多开始关注大模型2,但对于大模型落地而言,除了先进的算法,其背后的MLsystem(机器学习系统), 从分布式训练到高效推理的完整链路同样重要, 好的基础设施是应用爆发的基础. 作为一个入坑MLsys快两年半的练习生, 本文主要围…

jsp驾校管理系统Myeclipse开发mysql数据库web结构java编程计算机网页项目

一、源码特点 JSP 驾校管理系统 是一套完善的web设计系统&#xff0c;对理解JSP java编程开发语言有帮助&#xff0c;系统具有完整的源代码和数据库&#xff0c;系统采用serlvetdaobean mvc 模式&#xff0c;系统主要采用B/S模式开发。开发环境为TOMCAT7.0,Myeclipse8.5开发…

C#面:ASP.NET 的身份验证方式有哪些

C# ASP.NET 提供了多种身份验证方式&#xff0c;常用的有以下几种&#xff1a; Forms 身份验证&#xff1a;Forms 身份验证是 ASP.NET 中最常用的身份验证方式之一。它基于 cookie来跟踪用户的身份认证状态。在 Forms 身份验证中&#xff0c;用户在登录页面输入用户名和密码后…

解码Starknet Verifier:深入逆向工程之旅

1. 引言 Sandstorm为&#xff1a; 能提交独立proof给StarkWare的Ethereum Verifier&#xff0c;的首个开源的STARK prover。 开源代码见&#xff1a; https://github.com/andrewmilson/sandstorm&#xff08;Rust&#xff09; L2Beat 提供了以太坊上Starknet的合约架构图&…

单机多GPU的训练及debug中vscode下launch.json内容设置

1.预配置 Local_rank:当前机子上的第几块GPU。这里设置为-1&#xff0c;后续多线程自动分配显卡。 Cuda_visible_devices:指定分配资源到几块显卡上&#xff0c;这里‘0&#xff0c;1&#xff0c;2&#xff0c;3’就是这四张gpu的id。 os.environ[LOCAL_RANK] -1 os.enviro…

rust可变全局静态数组用法

extern crate alloc; use alloc::vec::Vec; use core::mem::ManuallyDrop; use log::info; use uefi::println; pub static mut gbuf:&static mut [i32] &mut [0; 0x1000]; pub fn testdumphex() -> i32 { info!(“testdumphex!”); let mut hexvec Vec::new();…

农村公交与异构无人机协同配送优化

针对农村公交与异构无人机协同配送的优化问题,可以从以下几个方面进行探讨: 1. 融合公交与无人机配送 公交物流体系:利用农村公交网络,建立以公交车辆为基础的物流配送体系。公交车辆可以沿途收集或投递货物,提高物流配送效率。无人机辅助配送:在公交物流体系的基础上,…

Linux学习系列文件管理之输出与重定向

在 Linux 中有三个经常用到的输入输出流&#xff0c;他们分别是&#xff1a; 标准输入&#xff08;stdin&#xff09;标准输出&#xff08;stdout&#xff09;标准错误&#xff08;stderr&#xff09; 在 Linux 系统中&#xff0c;系统保留了 0&#xff08;标准输入&#xff…

C语言/数据结构——每日一题(反转链表)

一.前言 大家好&#xff01;今天又是每日一题环节。今天我为大家分享了一道单链表题——反转链表。 废话不多说&#xff0c;让我们直接进入正题吧。 二.正文 1.1题目信息 这是一道leetCode上面的一道题&#xff1a;https://leetcode.cn/problems/reverse-linked-list 1.2解…

2.2 Java全栈开发前端+后端(全栈工程师进阶之路)-前端框架VUE3-基础-Vue基本语法

文本渲染指令 文本渲染指令-v-html与v-text Vue使用了基于HTML的模板语法&#xff0c;允许开发者声明式地将DOM绑定至底层Vue实例的数据。所有Vue的模板都是 合法的HTML&#xff0c;所以能被遵循规范的浏览器和HTML解析器解析。 在前面&#xff0c;我们一直使用的是字符串插…

Java面试八股之强软弱虚引用的概念及区别

Java中强软弱虚引用的概念及区别 在Java中&#xff0c;强引用、软引用、弱引用和虚引用是四种不同类型的引用&#xff0c;它们在对象生命周期管理、垃圾收集&#xff08;Garbage Collection, GC&#xff09;以及内存管理方面有着不同的行为和用途。以下是它们的概念和主要区别…

Java 中的自定义排序实现方法

文章目录 Java 中的自定义排序实现方法1. 使用自定义比较器对数组进行排序1.1 实现Comparator接口1.2 使用Arrays.sort()方法1.3 匿名内部类1.4 代码结果 2. 使用自定义比较器对集合进行排序2.1 实现Comparable接口2.2 使用Collections.sort()方法2.3 使用Lambda表达式2.4 代码…

2.Neo4j的搭建启动

Graph Database 图数据库 版本对应关系 官网都是高版本&#xff0c;推荐使用下载地址可以找到社区老版本&#xff1a; https://we-yun.com/doc/neo4j/ neo4j.bat 启动脚本 cypher-shell.bat 执行CQL语句的。 import文件夹可以放入excel,csv等数据文件&#xff0c;导入到…