element el-switch切换前先确认

// 设置禁用
<el-switch v-model="scope.row.switch" disabled @click.native="changeSwitch(scope.row)"></el-switch>

    changeSwitch (e, row) {
      let rows = {...row}
      let msg = `是否确定${rows.switch ? '关闭' : '开启'?}`
      this.$confirm(msg, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then( () => {
        // 业务逻辑
      })
    },


// 去除switch禁用 css
  .el-switch.is-disabled{
    opacity: 1;
  }
  .el-switch.is-disabled .el-switch__core, .el-switch.is-disabled .el-switch__label{
    cursor: pointer;
  }
 
  
原文地址:https://www.cnblogs.com/zhangrenjie/p/14334157.html