Switch

支持v-model双向绑定

<template>
  <div>
    <p>
      <z-switch v-model="checked" size="small"/>
      <z-switch v-model="checked" size="middle"/>
      <z-switch v-model="checked" size="large"/>
    </p>
    <z-button type="primary" @click="triggerHandle">通过checked改变</z-button>
    <h4>禁用</h4>
    <p>
      <z-switch disabled />
      <z-switch :value="true" disabled />
    </p>
  </div>
</template>
<script>
import Switch from "../../../src/components/switch/switch.vue";
import Button from "../../../src/components/button/button.vue";
export default {
  data() {
    return {
      checked: false
    };
  },
  components: {
    "z-switch": Switch,
    "z-button": Button
  },
  methods: {
    triggerHandle() {
      this.checked = !this.checked;
    }
  }
};
</script>

Props

属性 含义 类型 默认
value 是否被选中 Boolean false
size 组件大小 String: small,middle,large middle
disabled 是否禁用 Boolean false

Events

属性 含义 类型 默认
change value改变时触发 Function: (value)=>{}