遇到问题:点击开关后,弹窗之后还未进行选择,状态已经改变了
原因: 数据绑定使用的是v-model
解决:改成:value
<template slot-scope="scope">
<el-switch
:value="scope.row.status"
:active-value="0"
:inactive-value="1"
@change="handleStatusChange(scope.row)"
></el-switch>
</template>
handleStatusChange(row) {
let text = row.status == "0" ? "停用" : "启用";
this.$confirm('确认要"' + text + '""' + row.userName + '"用户吗?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return changeUserStatus(row.userId, status);
}).then(() => {
this.msgSuccess(text + "成功");
this.getList();
}).catch(function() {
});
},
网友评论