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;
  }
 
  

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章