switch.vue 620 B

12345678910111213141516171819202122
  1. <template>
  2. <div class="input switch" :style="{ width, height }" :class="{disabled}">
  3. <input
  4. class="replace-input"
  5. :disabled="disabled"
  6. :id="id"
  7. type="checkbox"
  8. :checked="props.modelValue"
  9. @input="ev => emit('update:modelValue', ev.target.checked)"
  10. >
  11. <span class="replace"></span>
  12. </div>
  13. </template>
  14. <script setup>
  15. import { switchPropsDesc } from './state'
  16. import { randomId } from '../../utils'
  17. import { defineProps, defineEmits } from 'vue'
  18. const props = defineProps(switchPropsDesc)
  19. const emit = defineEmits(['update:modelValue'])
  20. const id = randomId(4)
  21. </script>