角色列表-通过路由展示角色列表组件
1.在 power 文件夹下,新建 Roles.vue
2.在 index.js 中进行导入
// 全局导入
import Roles from '../components/power/Roles.vue'
{
path: '/home',
component: Home,
redirect: '/welcome',
children: [
{
path: '/welcome', component: Welcome },
{
path: '/users', component: Users },
{
path: '/rights', component: Rights },
// 作为 home 页面的子路由
{
path: '/roles', component: Roles }
]
}
角色列表-绘制基本布局结构并获取列表数据
1.卡片视图布局
<!-- 卡片视图 -->
<el-card>
<!-- 添加角色按钮区域 -->
<el-row>
<el-col>
<el-button type="primary">添加角色</el-button>
</el-col>
</el-row>
</el-card>
2.通过调用API获取数据
data () {
return {
// 所有角色列表数据
roleList: []
}
},
// 生命周期函数
created () {
this.getRolesList()
},
methods: {
// 获取所有角色的列表
async getRolesList (