1.$message
if (res.meta.status !== 200)
return this.$message.error('获取用户列表失败!')
}
//这个this.$message 等价于Vue.prototype.$message 都封装在组件库中,只要是Vue实例都可以调用
//是一个挂载在顶级的对象
2. v-table索引列的添加
只需要在v-table下添加:
3.el-switch的使用(插槽作用域的使用)
<el-table-column label="状态">
<!-- 作用域插槽,找到当前行对应的数据 -->
<!-- 定义了一个作用域插槽,通过slot-scope接收了当前的数据 -->
<!-- 如果插槽作用域和prop同时存在 插槽作用域会覆盖prop -->
<template slot-scope="scope">
<!-- {{scope.row}} -->
<el-switch v-model="scope.row.mg_state">
</el-switch>
</template>
</el-table-column>
这里的slot-scope=“scope” 是来获取:data绑定的数据,scope可以随便替换其他名称,只是定义对象来代表取得的data数据,便于使用,所以下面使用scope.row.mg_state获得数据。