element ui switch开关 点击按钮后,弹窗确认再改变开关状态

<el-switch
        v-model="autoUpdate"
        active-color="#5eb058"
        inactive-color="#cccccc"
        disabled
        @click.native="handelUpdate(autoUpdate)">
 </el-switch>
.el-switch.is-disabled .el-switch__core, .el-switch.is-disabled .el-switch__label{
      cursor: pointer;
    } 
 // 点击开启开关
    handelUpdate (autoUpdate) {
      let strOpen = '是否确认开启开关。'
      let strClose = '是否确认关闭开关。'
      if (!autoUpdate) {
       // 弹窗询问,这个是封装过的element ui 弹窗
      this.wConfirmTip('开启开关', strOpen, () => {
        this.autoUpdate = true
        })
      } else {
        this.wConfirmTip('关闭开关', strClose, () => {
          this.autoUpdate = false
        })
      }
    },

前面直接贴代码了。

需求:点击开关,根据开启或者关闭转态,弹出弹窗询问是否开启/关闭,点击确认开启后开关显示成为开启状态样式。

猜你喜欢

转载自blog.csdn.net/ymumi/article/details/82457124