zoukankan      html  css  js  c++  java
  • 左侧折叠菜单在sessionStorage中保存左侧菜单的激活状态

    1.给el-menu添加 :default-active="activePath" default-active(当前激活菜单的index)

            <el-menu background-color="#333744" text-color="#fff" active-text-color="#409EFF" unique-opened :collapse="isCollapse" :collapse-transition="false" router :default-active="activePath">

    2.data中定义被激活的链接地址

    data(){
      return{
        //被激活的链接地址
        activePath: ''
     }  
    }
    

    3.点击菜单导航时,把对应的导航地址保存到sesstionStorage中

    <el-menu-item :index="'/' + subItem.path" v-for="subItem in item.children" :key="subItem.id"
                              @click="saveNavState('/' + subItem.path)">
    

    4.实现svaeNavState方法

    // 保存连接的激活状态
        saveNavState (activePath) {
          window.sessionStorage.setItem('activePath', activePath)
          // 重新赋值
          this.activePath = activePath
        }
    

    5.在created生命周期中取出保存的链接地址

    created () {
        this.activePath = window.sessionStorage.getItem('activePath')
      },
    

      

  • 相关阅读:
    二维数组排序
    php-快速排序
    sql优化相关
    全页面静态化缓存
    php--1-100相加之和
    php--阶乘
    socket
    posix_getpid 函数win下失效问题
    水仙花数
    常用的魔术方法
  • 原文地址:https://www.cnblogs.com/WorldEye/p/13862669.html
Copyright © 2011-2022 走看看