按照角色分配

        

单个角色 $auth.hasRole('cw') 在任何地方可以使用
<el-table-column
        label="联系方式"
        v-if="$auth.hasRole('cw')"
        align="center"
        prop="phone"
      />
多个角色 $auth.hasRoleOr(['cw','dd']) 在任何地方可以使用
<el-table-column
        label="客户名称"
        v-if="$auth.hasRoleOr(['cw','dd'])"
        align="center"
        prop="deptName"
      />
在button a标签中使用 在table span等中无法使用
       // 单个 
<el-button
            size="mini"
            type="text"
            @click='handleDetailCw(scope.row)'
            v-hasRole="['cw']"
            >客户详情</el-button>
        //多个
<a disabled
            v-hasRole="['gly','dd']"
          >{{ scope.row.source == "1" ? "客户申请" : "" }}</a>

根据角色权限展示该角色下的路由
 {
        path: '/',
        component: Layout,
        roles: ['kf'],
        hidden: true,
        children: [{
            path: 'dept/detail-kf',
            component: () =>
                import('@/views/system/dept/detail-kf'),
            name: 'dept/detail-kf',
            meta: { title: '客户详情', activeMenu: '/system/dept/indexkf' }
        }]
    },

按照

Logo

快速构建 Web 应用程序

更多推荐