mirror of
https://github.com/keven1024/015.git
synced 2026-05-26 15:13:30 +00:00
25 lines
542 B
Vue
25 lines
542 B
Vue
<template>
|
|
<Button type="button" @click="(e) => {
|
|
e.preventDefault()
|
|
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)
|
|
|
|
watchEffect(async () => {
|
|
const { valid } = await form?.validate()
|
|
isValid.value = valid
|
|
})
|
|
|
|
const emit = defineEmits<{
|
|
(e: 'click', form: ReturnType<typeof useFormContext>): void
|
|
}>()
|
|
</script>
|