fs-switch.vue 661 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <template>
  2. <switch
  3. class="fs-switch"
  4. :checked="checked"
  5. :color="color"
  6. :disabled="disabled"
  7. :class="[size]"
  8. @change="change">
  9. </switch>
  10. </template>
  11. <script setup>
  12. const props = defineProps({
  13. checked: Boolean,
  14. disabled: Boolean,
  15. color: {
  16. type: String,
  17. default: '#0063F5'
  18. },
  19. size: {
  20. type: String,
  21. validator(value) {
  22. return ['small', 'medium'].includes(value)
  23. }
  24. }
  25. })
  26. const emits = defineEmits(['change'])
  27. const change = e => {
  28. emits('change', e.detail.value)
  29. }
  30. </script>
  31. <style lang="scss" scoped>
  32. .fs-switch{
  33. transform: scale(0.8);
  34. &.medium{
  35. transform: scale(0.6);
  36. }
  37. &.small{
  38. transform: scale(0.5);
  39. }
  40. }
  41. </style>