vuejs3+elementPlus后台管理系统,左侧菜单栏制作,跳转、默认激活菜单

本文主要是介绍vuejs3+elementPlus后台管理系统,左侧菜单栏制作,跳转、默认激活菜单,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

默认激活菜单,效果: 

默认激活菜单,效果1:

默认激活菜单,效果2:

跳转链接效果:

制作:

<script setup>
import {useUserStore} from "@/stores/userStore.js";
import {ref} from "vue";const userStore = useUserStore()
//默认激活菜单
const defaultMenu = ref('/home')
</script><template><el-menuactive-text-color="#409EFF"background-color="#32363f":default-active="defaultMenu"text-color="#fff"@open="handleOpen"@close="handleClose"router><el-sub-menu :index="ind+1" v-for="(menuItem,ind) in userStore.userInfo.menus" :id="menuItem.id"><template #title><el-icon><component :is="menuItem.icon"></component></el-icon><span>{{menuItem.name}}</span></template><el-menu-item :index="childItem.frontpath" v-for="(childItem,childInd ) in menuItem.child"><template #title><el-icon><component :is="childItem.icon"></component></el-icon><span>{{childItem.name}}</span></template></el-menu-item></el-sub-menu></el-menu>
</template><style scoped></style>

代码解析,实现路径跳转:

代码解析,默认激活菜单

数据格式:

{"status": 200,"id": 3,"username": "admin","avatar": "http:xxxxxxxxxxx.com/public/642438a225ad5.jpg","super": 1,"role": {"id": 2,"name": "超级管理员"},"menus": [{"id": 598,"rule_id": 0,"status": 1,"create_time": "2024-06-11 23:22:32","update_time": "2024-06-19 22:32:52","name": "后台首页","desc": null,"frontpath": "","condition": "","menu": 1,"order": 1,"icon": "House","method": "","child": [{"id": 599,"rule_id": 598,"status": 1,"create_time": "2024-06-11 23:24:51","update_time": "2024-06-19 22:32:55","name": "后台首页","desc": null,"frontpath": "/home","condition": "","menu": 1,"order": 50,"icon": "AddLocation","method": "","child": []}]},{"id": 562,"rule_id": 0,"status": 1,"create_time": "2024-05-29 21:18:00","update_time": "2024-06-11 23:19:37","name": "图库管理","desc": null,"frontpath": "","condition": "调度","menu": 1,"order": 2,"icon": "Opportunity","method": "POST","child": [{"id": 563,"rule_id": 562,"status": 1,"create_time": "2024-05-29 21:19:18","update_time": "2024-05-30 14:17:37","name": "图库管理","desc": null,"frontpath": "/image/list","condition": "","menu": 1,"order": 2,"icon": "PictureFilled","method": "","child": [{"id": 571,"rule_id": 563,"status": 1,"create_time": "2024-05-30 14:16:47","update_time": "2024-05-30 14:16:47","name": "11","desc": null,"frontpath": "11","condition": "","menu": 1,"order": 50,"icon": "AddLocation","method": "","child": [{"id": 597,"rule_id": 571,"status": 1,"create_time": "2024-06-11 17:06:34","update_time": "2024-06-11 17:06:34","name": "图库","desc": null,"frontpath": "","condition": "","menu": 1,"order": 50,"icon": "AlarmClock","method": "","child": []}]}]}]},{"id": 556,"rule_id": 0,"status": 1,"create_time": "2024-05-29 18:35:06","update_time": "2024-05-30 16:45:55","name": "管理员管理","desc": null,"frontpath": "","condition": "","menu": 1,"order": 3,"icon": "Avatar","method": "","child": [{"id": 557,"rule_id": 556,"status": 1,"create_time": "2024-05-29 18:36:05","update_time": "2024-05-30 16:45:54","name": "管理员管理","desc": null,"frontpath": "/manager/list","condition": "","menu": 1,"order": 50,"icon": "AddLocation","method": "","child": []},{"id": 558,"rule_id": 556,"status": 1,"create_time": "2024-05-29 18:37:14","update_time": "2024-06-06 14:42:46","name": "权限管理","desc": null,"frontpath": "/access/list","condition": "","menu": 1,"order": 50,"icon": "AlarmClock","method": "","child": []},{"id": 587,"rule_id": 556,"status": 1,"create_time": "2024-05-30 16:32:43","update_time": "2024-06-06 14:42:50","name": "角色管理","desc": null,"frontpath": "/role/list","condition": "","menu": 1,"order": 50,"icon": "AddLocation","method": "","child": []}]},{"id": 574,"rule_id": 0,"status": 1,"create_time": "2024-05-30 14:29:44","update_time": "2024-05-30 17:25:32","name": "用户管理","desc": null,"frontpath": "","condition": "","menu": 1,"order": 4,"icon": "User","method": "","child": [{"id": 575,"rule_id": 574,"status": 1,"create_time": "2024-05-30 14:30:55","update_time": "2024-05-30 14:30:55","name": "用户管理","desc": null,"frontpath": "/user/list","condition": "","menu": 1,"order": 50,"icon": "UserFilled","method": "","child": []},{"id": 576,"rule_id": 574,"status": 1,"create_time": "2024-05-30 14:33:11","update_time": "2024-05-30 14:33:11","name": "会员等级","desc": null,"frontpath": "/level/list","condition": "","menu": 1,"order": 50,"icon": "DataLine","method": "","child": []}]},{"id": 6,"rule_id": 0,"status": 1,"create_time": "2019-08-11 13:36:36","update_time": "2024-05-30 16:45:31","name": "商品管理","desc": "shop_goods_list","frontpath": null,"condition": null,"menu": 1,"order": 5,"icon": "shopping-bag","method": "GET","child": [{"id": 15,"rule_id": 6,"status": 1,"create_time": "2019-12-28 13:44:32","update_time": "2024-05-30 15:44:44","name": "规格管理","desc": "shop_sku_list","frontpath": "/skus/list","condition": "","menu": 1,"order": 19,"icon": "aim","method": "GET","child": []},{"id": 13,"rule_id": 6,"status": 1,"create_time": "2019-12-28 13:42:13","update_time": "2024-05-30 15:45:04","name": "商品管理","desc": "shop_goods_list","frontpath": "/goods/list","condition": "","menu": 1,"order": 20,"icon": "shopping-cart-full","method": "GET","child": [{"id": 565,"rule_id": 13,"status": 1,"create_time": "2024-05-30 12:45:24","update_time": "2024-05-30 12:45:24","name": "5555","desc": null,"frontpath": "","condition": "","menu": 1,"order": 50,"icon": "AlarmClock","method": "","child": []}]},{"id": 14,"rule_id": 6,"status": 1,"create_time": "2019-12-28 13:44:00","update_time": "2024-05-29 18:59:54","name": "分类管理","desc": "shop_category_list","frontpath": "/category/list","condition": "","menu": 1,"order": 20,"icon": "menu","method": "GET","child": []}]},{"id": 511,"rule_id": 0,"status": 1,"create_time": "2024-05-25 13:17:25","update_time": "2024-05-30 16:45:31","name": "订单管理","desc": null,"frontpath": "","condition": "","menu": 1,"order": 6,"icon": "Tickets","method": "","child": [{"id": 512,"rule_id": 511,"status": 1,"create_time": "2024-05-25 13:18:03","update_time": "2024-05-28 14:44:26","name": "订单管理","desc": null,"frontpath": "/order/list","condition": "","menu": 1,"order": 50,"icon": "Tickets","method": "","child": [{"id": 550,"rule_id": 512,"status": 1,"create_time": "2024-05-28 21:15:38","update_time": "2024-05-28 21:15:38","name": "sssss","desc": null,"frontpath": "","condition": "","menu": 1,"order": 50,"icon": "","method": "","child": []}]}]},{"id": 577,"rule_id": 0,"status": 1,"create_time": "2024-05-30 14:34:37","update_time": "2024-05-30 16:45:31","name": "分销管理","desc": null,"frontpath": "","condition": "","menu": 1,"order": 7,"icon": "Setting","method": "","child": [{"id": 579,"rule_id": 577,"status": 1,"create_time": "2024-05-30 14:36:27","update_time": "2024-05-30 14:36:27","name": "分销员管理","desc": null,"frontpath": "/distribution/index","condition": "","menu": 1,"order": 50,"icon": "User","method": "","child": []}]},{"id": 513,"rule_id": 0,"status": 1,"create_time": "2024-05-25 13:45:56","update_time": "2024-05-30 16:45:32","name": "优惠券管理","desc": null,"frontpath": "","condition": "","menu": 1,"order": 8,"icon": "AddLocation","method": "","child": [{"id": 545,"rule_id": 513,"status": 1,"create_time": "2024-05-28 14:49:34","update_time": "2024-05-29 18:59:56","name": "优惠券管理","desc": null,"frontpath": "/coupon/list","condition": "","menu": 1,"order": 50,"icon": "Coin","method": "","child": []}]},{"id": 515,"rule_id": 0,"status": 1,"create_time": "2024-05-25 14:14:33","update_time": "2024-05-30 16:45:33","name": "评论管理","desc": null,"frontpath": "","condition": "","menu": 1,"order": 9,"icon": "Aim","method": "","child": [{"id": 544,"rule_id": 515,"status": 1,"create_time": "2024-05-28 14:49:02","update_time": "2024-05-29 18:59:57","name": "评论管理","desc": null,"frontpath": "/comment/list","condition": "","menu": 1,"order": 50,"icon": "ChatLineSquare","method": "","child": []}]},{"id": 578,"rule_id": 0,"status": 1,"create_time": "2024-05-30 14:35:29","update_time": "2024-05-30 16:45:33","name": "公告管理","desc": null,"frontpath": "","condition": "","menu": 1,"order": 10,"icon": "ChatLineSquare","method": "","child": [{"id": 581,"rule_id": 578,"status": 1,"create_time": "2024-05-30 14:38:53","update_time": "2024-05-30 14:38:53","name": "公告管理","desc": null,"frontpath": "/notice/list","condition": "","menu": 1,"order": 50,"icon": "ChatLineRound","method": "","child": []},{"id": 585,"rule_id": 578,"status": 1,"create_time": "2024-05-30 15:05:49","update_time": "2024-05-30 16:44:52","name": "测试界面","desc": null,"frontpath": "","condition": "","menu": 1,"order": 50,"icon": "","method": "","child": []}]}],"ruleNames": ["调度,POST","createRule,POST","updateRule,POST","deleteRule,POST","getRuleList,GET","updateRuleStatus,POST","createRole,POST","updateRole,POST","deleteRole,POST","getRoleList,GET","updateRoleStatus,POST","getGoodsList,GET","getCategoryList,GET","createCategory,POST","sortCategory,POST","updateCategory,POST","updateCategoryStatus,POST","deleteCategory,DELETE","createSkus,POST","deleteSkus,POST","updateSkus,POST","updateSkusStatus,POST","getUserLevelList,GET","createUserLevel,POST","updateUserLevel,POST","updateUserLevelStatus,POST","deleteUserLevel,POST","deleteManager,POST","getManagerList,GET","updateManager,POST","updateManagerStatus,POST","readGoods,GET","updateGoodsSkus,POST","setGoodsBanner,POST","restoreGoods,POST","destroyGoods,POST","deleteGoods,POST","updateGoodsStatus,POST","createGoods,POST","updateGoods,POST","checkGoods,POST","createGoodsSkusCard,POST","sortGoodsSkusCard,POST","updateGoodsSkusCard,POST","deleteGoodsSkusCard,POST","createGoodsSkusCardValue,POST","updateGoodsSkusCardValue,POST","deleteGoodsSkusCardValue,POST","getNoticeList,GET","createNotice,POST","updateNotice,POST","deleteNotice,POST","getCategoryGoods,GET","connectCategoryGoods,POST","deleteCategoryGoods,POST","setRoleRules,POST"]
}

这篇关于vuejs3+elementPlus后台管理系统,左侧菜单栏制作,跳转、默认激活菜单的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1080314

相关文章

PyCharm如何设置新建文件默认为LF换行符

《PyCharm如何设置新建文件默认为LF换行符》:本文主要介绍PyCharm如何设置新建文件默认为LF换行符问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录PyCharm设置新建文件默认为LF换行符设置换行符修改换行符总结PyCharm设置新建文件默认为LF

MySQL9.0默认路径安装下重置root密码

《MySQL9.0默认路径安装下重置root密码》本文主要介绍了MySQL9.0默认路径安装下重置root密码,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们... 目录问题描述环境描述解决方法正常模式下修改密码报错原因问题描述mysqlChina编程采用默认安装路径,

Java访问修饰符public、private、protected及默认访问权限详解

《Java访问修饰符public、private、protected及默认访问权限详解》:本文主要介绍Java访问修饰符public、private、protected及默认访问权限的相关资料,每... 目录前言1. public 访问修饰符特点:示例:适用场景:2. private 访问修饰符特点:示例:

idea如何开启菜单栏

《idea如何开启菜单栏》文章介绍了如何通过修改IntelliJIDEA的样式文件`ui.lnf.xml`来重新显示被关闭的菜单栏,并分享了解决问题的步骤... 目录ijsdea开启菜单栏第一步第二步总结idea开启菜单栏手贱关闭了idea的js菜单栏,花费了半个小时终于解决,记录并分享一下第一步找

Linux使用nohup命令在后台运行脚本

《Linux使用nohup命令在后台运行脚本》在Linux或类Unix系统中,后台运行脚本是一项非常实用的技能,尤其适用于需要长时间运行的任务或服务,本文我们来看看如何使用nohup命令在后台... 目录nohup 命令简介基本用法输出重定向& 符号的作用后台进程的特点注意事项实际应用场景长时间运行的任务服

更改docker默认数据目录的方法步骤

《更改docker默认数据目录的方法步骤》本文主要介绍了更改docker默认数据目录的方法步骤,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一... 目录1.查看docker是否存在并停止该服务2.挂载镜像并安装rsync便于备份3.取消挂载备份和迁

使用Python制作一个PDF批量加密工具

《使用Python制作一个PDF批量加密工具》PDF批量加密‌是一种保护PDF文件安全性的方法,通过为多个PDF文件设置相同的密码,防止未经授权的用户访问这些文件,下面我们来看看如何使用Python制... 目录1.简介2.运行效果3.相关源码1.简介一个python写的PDF批量加密工具。PDF批量加密

禁止平板,iPad长按弹出默认菜单事件

通过监控按下抬起时间差来禁止弹出事件,把以下代码写在要禁止的页面的页面加载事件里面即可     var date;document.addEventListener('touchstart', event => {date = new Date().getTime();});document.addEventListener('touchend', event => {if (new

Android实现任意版本设置默认的锁屏壁纸和桌面壁纸(两张壁纸可不一致)

客户有些需求需要设置默认壁纸和锁屏壁纸  在默认情况下 这两个壁纸是相同的  如果需要默认的锁屏壁纸和桌面壁纸不一样 需要额外修改 Android13实现 替换默认桌面壁纸: 将图片文件替换frameworks/base/core/res/res/drawable-nodpi/default_wallpaper.*  (注意不能是bmp格式) 替换默认锁屏壁纸: 将图片资源放入vendo

Vue3项目开发——新闻发布管理系统(六)

文章目录 八、首页设计开发1、页面设计2、登录访问拦截实现3、用户基本信息显示①封装用户基本信息获取接口②用户基本信息存储③用户基本信息调用④用户基本信息动态渲染 4、退出功能实现①注册点击事件②添加退出功能③数据清理 5、代码下载 八、首页设计开发 登录成功后,系统就进入了首页。接下来,也就进行首页的开发了。 1、页面设计 系统页面主要分为三部分,左侧为系统的菜单栏,右侧