iview 开关变化时控制状态的变更

1.css
.switch{
 pointer-events:none
}

2.js
var App = new Vue({
  template: '<i-switch @click="change" :value="open"class="switch" ></i-switch>',
  data(){
    return {
      open:false
    }
  },
  methods:{
    change(open){
      this.$Modal.confirm({
        title: '切换提示',
        content: '<p>开关状态即将发生更改,是否继续</p>',
        onOk: () => {
          this.open = true;
          this.$Message.info('当前状态是'+ this.open);
        },

        onCancel:()=>{
          this.open = false;
          this.$Message.info('当前状态是'+ this.open);
        }
      });
    }
  }
});
  


  

原文地址:https://www.cnblogs.com/Doduo/p/10656139.html