Checkbox.vue 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <!--
  2. Case à cocher
  3. @see https://vuetifyjs.com/en/components/checkboxes/
  4. -->
  5. <template>
  6. <v-container
  7. class="px-0"
  8. fluid
  9. >
  10. <v-checkbox
  11. v-model="data"
  12. :value="data"
  13. :label="$t(label_field)"
  14. :disabled="readonly"
  15. :error="error"
  16. @change="onChange($event)"
  17. />
  18. </v-container>
  19. </template>
  20. <script lang="ts">
  21. import { defineComponent } from '@nuxtjs/composition-api'
  22. import {$useError} from "~/composables/form/useError";
  23. export default defineComponent({
  24. props: {
  25. field: {
  26. type: String,
  27. required: false,
  28. default: null
  29. },
  30. label: {
  31. type: String,
  32. required: false,
  33. default: null
  34. },
  35. data: {
  36. type: Boolean,
  37. required: false
  38. },
  39. readonly: {
  40. type: Boolean,
  41. required: false
  42. }
  43. },
  44. setup (props, {emit}) {
  45. const {error, onChange} = $useError(props.field, emit)
  46. return {
  47. label_field: props.label ?? props.field,
  48. error,
  49. onChange
  50. }
  51. }
  52. })
  53. </script>
  54. <style scoped>
  55. </style>