mirror of
https://github.com/keven1024/015.git
synced 2026-05-26 15:13:30 +00:00
25 lines
537 B
Vue
25 lines
537 B
Vue
<template>
|
|
<Button @click="() => emit('click', form)" :disabled="!isValid">
|
|
<slot />
|
|
</Button>
|
|
</template>
|
|
<script setup lang="ts">
|
|
import { Button } from '~/components/ui/button'
|
|
import { useFormContext } from 'vee-validate'
|
|
const form = useFormContext()
|
|
|
|
const isValid = ref(false)
|
|
watch(
|
|
() => form?.values,
|
|
async () => {
|
|
const { valid } = await form?.validate()
|
|
isValid.value = valid
|
|
},
|
|
{ deep: true }
|
|
)
|
|
|
|
const emit = defineEmits<{
|
|
(e: 'click', form: ReturnType<typeof useFormContext>): void
|
|
}>()
|
|
</script>
|