1. 首先請求服務(wù)器,獲取當(dāng)前用戶的權(quán)限數(shù)據(jù),比如請求 this.$http.get("rights/list");
2. 獲取到權(quán)限數(shù)據(jù)之后,在列表中使用v-if v-if-else的組合來展示不同的內(nèi)容
<template>
<div>
<!-- 面包屑導(dǎo)航區(qū) -->
<el-breadcrumb separator-class="el-icon-arrow-right">
<el-breadcrumb-item :to="{ path: '/home' }">首頁</el-breadcrumb-item>
<el-breadcrumb-item>權(quán)限管理</el-breadcrumb-item>
<el-breadcrumb-item>權(quán)限列表</el-breadcrumb-item>
</el-breadcrumb>
<!-- 卡片視圖 -->
<el-card>
<el-table :data="rightsList" border stripe>
<el-table-column type="index" label="#"></el-table-column>
<el-table-column label="權(quán)限名稱" prop="authName"></el-table-column>
<el-table-column label="路徑" prop="path"></el-table-column>
<el-table-column label="權(quán)限等級" prop="level">
<template slot-scope="scope">
<el-tag v-if="scope.row.level === '0'">一級</el-tag>
<el-tag type="success" v-else-if="scope.row.level === '1'">二級</el-tag>
<el-tag type="danger" v-else>三級</el-tag>
</template>
</el-table-column>
</el-table>
</el-card>
</div>
</template>
<script>
export default {
data() {
return {
// 權(quán)限列表
rightsList: []
};
},
created() {
this.getRightsList();
},
methods: {
async getRightsList() {
//獲取權(quán)限列表數(shù)據(jù)
const { data: res } = await this.$http.get("rights/list");
if (res.meta.status !== 200) {
return this.$message.error("獲取權(quán)限列表失??!");
}
this.rightsList = res.data;
}
}
};
</script>
<style lang='less' scoped>
</style>