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

 

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