• vue做页面按钮权限--分析


    import * as types from '../mutation-types'
    const state = {
      btnCode: getBtnCode(),
    }
    const mutations = {
      getBtnObj(state, btnCodeObj) {
        // 登录成功后获取--按钮权限
        state.btnCode = btnCodeObj;
      },
    }
    const getters = {
      btnCode: state => state.btnCode
    }
    const actions = {
      actionsBtnList({ commit }, btnlist) {
        commit('getBtnObj', setBtnList(btnlist))
      },
    }
    // 按钮--权限
    function setBtnList(list) {
      // 解决刷新后才出现按钮--权限的数据
      let codeObj = {
        '100010': btnCode('100010', list), // xxx按钮code码;
      }
      sessionStorage.setItem('btnObj', JSON.stringify(codeObj));
      let btnCodeObj = JSON.parse(sessionStorage.getItem('btnObj')) || {}
      return btnCodeObj
    }
    
    function getBtnCode() {
      return sessionStorage.getItem('btnObj') ? JSON.parse(sessionStorage.getItem('btnObj')) : {}
    }
    
    function btnCode(code, list) {
      // console.log(list,'按钮list')
      return list.findIndex(e => {
        return e.buttonCode == code
      })
    }
    
    export default {
      state,
      mutations,
      getters,
      actions
    }
  • 相关阅读:
    nepenthes用法
    honeydctl命令
    honeyd路由拓扑
    Linux Samba服务器的安装
    honeyd使用
    FreeRTOS 事件标志组
    epoll函数
    Java程序:从命令行接收多个数字,求和并输出结果
    《大道至简》第一章读后感
    【诗词歌赋】 杂感- 贺小妹
  • 原文地址:https://www.cnblogs.com/lhl66/p/11098574.html
Copyright © 2020-2023  润新知