若依框架中不同权限用户浏览不同首页内容

<template>
  <div class="dashboard-editor-container" v-if="rolesData.includes('admin')"> //admin 
    <panel-group @handleSetLineChartData="handleSetLineChartData" />
    <el-row :gutter="32">
      <el-col :xs="24" :sm="24" :lg="12">
        <div class="chart-wrapper">
          <div>进行中的考试</div>
            <centerRight1 style="width: 100%;" />
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="12">
        <div class="chart-wrapper" @click="getList">
          <div>考试总览</div>
          <line-chart/>
        </div>
      </el-col>
    </el-row>
    <el-row :gutter="32">
      <el-col :xs="24" :sm="24" :lg="24">
        <div class="chart-wrapper">
          <div>用户总览</div>
          <bar-chart />
        </div>
      </el-col>
    </el-row> 
  </div>
  <div v-else> //普通用户
    <p>Welcome, user!</p>
  </div>
</template>

<script>

import PanelGroup from './dashboard/PanelGroup'
import LineChart from './dashboard/LineChart'
import RaddarChart from './dashboard/RaddarChart'
import PieChart from './dashboard/PieChart'
import BarChart from './dashboard/BarChart'
import centerRight1 from './dashboard/centerRight1'

export default {
  name: 'Index',
  components: {
    PanelGroup,
    LineChart,
    RaddarChart,
    PieChart,
    BarChart,
    centerRight1
  },
  data() {
    return {
      rolesData:[],
     
    }
  },

  created() {
    this.getList();
  },
  
  methods: {
    getList(){
      this.$store.dispatch('GetInfo').then(res => {
        console.log(778899,res.roles);
        this.rolesData= res.roles;
        //res.roles.includes("admin")
        console.log(77889900,this.rolesData);
      });
    },
    
  
  }
}
</script>


</style>

1、v-if="rolesData.includes('admin')"
2getList(){
      this.$store.dispatch('GetInfo').then(res => {
        this.rolesData= res.roles;
      });
    },
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值