DefaultForm.vue 915 B

1234567891011121314151617181920212223242526272829303132333435
  1. <template>
  2. <QForm ref="formRef" v-bind="$attrs" @validation-error="onValidationError">
  3. <slot />
  4. </QForm>
  5. </template>
  6. <script setup>
  7. import { QForm } from "quasar";
  8. import { useTemplateRef } from "vue";
  9. import { useScroll } from "src/composables/useScroll";
  10. defineOptions({ inheritAttrs: false });
  11. const formRef = useTemplateRef("formRef");
  12. const { scrollToComponent } = useScroll();
  13. const onValidationError = (component) => {
  14. if (!component) return;
  15. component.focus?.();
  16. scrollToComponent(component);
  17. };
  18. const validate = (...args) => formRef.value?.validate(...args);
  19. const resetValidation = (...args) => formRef.value?.resetValidation(...args);
  20. const getValidationComponents = (...args) =>
  21. formRef.value?.getValidationComponents(...args);
  22. const submit = (...args) => formRef.value?.submit(...args);
  23. defineExpose({ validate, resetValidation, getValidationComponents, submit });
  24. </script>