当前位置: 首页 > news >正文

使用element-ui导航,进入对应的三级页面菜单保持点击状态

1.注意事项

01.路由中使用了keepAlive属性,要用keepAlive:true,不能等于false,使用false页面会刷新

2.使用的方法

3.项目实例

<template><div class="policy-home"><div class="policyNav"><el-menu :default-active="activeIndex"background-color="#486DC0"text-color="#FFFFFF"active-text-color="#FFF000"class="el-menu-demo"mode="horizontal":router="true"><el-menu-item index="/policyjisuan">政策计算器</el-menu-item><el-menu-item index="/searchP">检索</el-menu-item><el-menu-item index="/policyStoreGraphic">政策图解</el-menu-item><el-menu-item index="/applyNews">今日申报</el-menu-item><el-menu-item index="/original">政策原文</el-menu-item></el-menu></div><div class="navContent"><router-view></router-view></div></div>
</template>
<script>export default {data() {return {activeIndex: '/policyjisuan',};},watch: {// 监听路由变化'$route.path': {handler (routePath) {this.initMenuActive(routePath)},immediate: true}},methods: {initMenuActive (routePath) {//路由跳转时,标记在导航的哪个选项下对应的路由,css高亮显示if (routePath == '/loginPolicy') {this.activeIndex = '/policyjisuan'} else if(routePath == '/searchDetail'){this.activeIndex = '/searchP'} else if(routePath == '/applyDetail'){this.activeIndex = '/applyNews'} else if(routePath == '/calculateDetail'){this.activeIndex = '/policyjisuan'} else if(routePath == '/companyDetail'){this.activeIndex = '/policyjisuan'} else if(routePath == '/originalDetail'){this.activeIndex = '/original'} else {this.activeIndex = routePath}},}}
</script><style lang="scss" scoped>/* 导航下页面 */.navContent {min-height: 800px;padding-bottom: 70px;background-color: #fff;}.policyNav {.el-menu-item {text-align: center;border-bottom: none;width: 16%;font-size: 22px;font-weight: 500;background-color: #486DC0 !important;}.el-menu {background-color: #486DC0 !important;}}
</style>

路由配置

js文件
export default [{path: '/policyStoreIndex',name: '政策计算器导航页',redirect: '/policyjisuan',component: () =>import(/* webpackChunkName: "page" */ '@/views/home/policyStoreIndex'),meta: {keepAlive: true,isTab: false,isAuth: false},children: [{path: '/searchP',name: '检索',component: () =>import(/* webpackChunkName: "page" */ '@/views/home/policyStoreNew/searchP'),meta: {keepAlive: true,isTab: false,isAuth: false}}]}]   

http://www.lryc.cn/news/156723.html

相关文章:

  • golang字符串转64位整数
  • 创作纪念日-我的第1024天
  • 【线上问题】很抱歉,如果没有 JavaScript 支持,将不能正常工作
  • 便捷、快速、稳定、高性能!以 GPU 实例演示 Alibaba Cloud Linux 3 对 AI 生态的支持 | 龙蜥技术
  • 创新科技改变城市:智慧城市建设全景展望
  • Kotlin 环境下解决属性初始化问题
  • Java复习-20-接口(3)- 代理设计模式
  • 如何远程访问Linux MeterSphere一站式开源持续测试平台
  • LinuxUbuntu安装OpenWAF
  • LeetCode 剑指offer 09.用两个栈实现队列
  • 第三方软件检测机构有哪些资质,2023年软件测评公司推荐
  • Unity的GPUSkinning进一步介绍
  • Mysql redolog
  • 【设计模式】Head First 设计模式——桥模式 C++实现
  • CESM2代码下载
  • 编写OpenCL程序的基本步骤
  • 计算机网络之TCP/IP协议第一篇:网络基础知识
  • 虚拟机扩容
  • Linux下的系统编程——进程间的通信(九)
  • Qt QtableWidget、QtableView表格删除选中行、删除单行、删除多行
  • 【代码随想录day24】不同的二叉搜索树
  • 数学建模--Subplot绘图的Python实现
  • JMeter(三十九):selenium怪异的UI自动化测试组合
  • c++ 移动构造方法为什么要加noexcept
  • 鸿鹄工程项目管理系统 Spring Cloud+Spring Boot+前后端分离构建工程项目管理系统
  • 手把手教你搭建园林园艺小程序商城
  • Java Iterator(迭代器)
  • Logstash同步MySQL数据到ElasticSearch
  • 【C++】运算符重载的示例实现和应用
  • Kubernetes禁止调度