mirror of
https://github.com/keven1024/015.git
synced 2026-05-26 23:19:37 +00:00
28 lines
585 B
Vue
28 lines
585 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)
|
|
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>
|