vue项目中在table表格中使用switch开关
<template slot-scope="scope"><el-switchv-model="scope.row.status":active-value="1":inactive-value="0"@change="switchChange($event, scope.row)"active-color="#13ce66".
·
<template slot-scope="scope">
<el-switch
v-model="scope.row.status"
:active-value="1"
:inactive-value="0"
@change="switchChange($event, scope.row)"
active-color="#13ce66"
inactive-color="#ff4949"
>
</el-switch>
</template>
scope.row.status 是后端返回的值 0 或 1 当前状态 0 停用 1 启用
switchChange(e, data) {
let url = ''
let message = ''
if (e == 1) {
url = '/tpPringTemplate/enable/'
message = '启用成功 !'
} else if (e == 0) {
url = '/tpPringTemplate/disable/'
message = '停用成功 !'
}
this.$ajax.get(`${url + data.ptId}`).then((res) => {
if (res.code == 0) return this.$message({ type: "success", message });
});
},
效果
更多推荐
已为社区贡献2条内容
所有评论(0)