作用域插槽
<!-- 状态 -->
<el-table-column prop="mg_state"
label="状态"
width="100">
<template slot-scope="scope">
<!-- {{scope.row}} -->
<el-switch v-model="scope.row.mg_state"
@change="userStateChanged(scope.row)">
</el-switch>
</template>
</el-table-column>
带请求参数
const { data: res } = await this.$http.get('users', { params: this.queryInfo })
动态参数
// 用户状态改变
async userStateChanged (userInfo) {
console.log(userInfo)
// 请求路径:users/:uId/state/:type
const { data: res } = await this.$http.put(`users/${userInfo.id}/state/${userInfo.mg_state}`)
}