美文网首页
element-ui的el-switch 点击时,保持当前状态不

element-ui的el-switch 点击时,保持当前状态不

作者: lovelydong | 来源:发表于2021-11-02 15:28 被阅读0次

    遇到问题:点击开关后,弹窗之后还未进行选择,状态已经改变了
    原因: 数据绑定使用的是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() {
              
            });
        },
    

    相关文章

      网友评论

          本文标题:element-ui的el-switch 点击时,保持当前状态不

          本文链接:https://www.haomeiwen.com/subject/bkzxzltx.html