<template>
  <div class="demo-switch-loading">
    <ui-switch
      v-model="value"
      :loading="loading"></ui-switch>
    <ui-switch
      v-model="value"
      :before-change="beforeChange"></ui-switch>
  </div>
</template>

<script>
import { Switch } from "amumu-ui"
export default {
  components: {
    "ui-switch": Switch,
  },
  data() {
    return {
      value: false,
      loading: true,
    }
  },
  methods: {
    beforeChange(checked) {
      return new Promise((resolve) => {
        setTimeout(() => resolve(!checked), 1500)
      })
    },
  },
}
</script>
