Files
certd/packages/ui/certd-client/src/components/loading-button.vue
T
xiaojunnuo 15740a6d8a chore:
2024-12-01 03:09:29 +08:00

25 lines
423 B
Vue

<template>
<a-button :loading="loading" @click="onClick">
<slot></slot>
</a-button>
</template>
<script setup lang="ts">
import { ref } from "vue";
const props = defineProps<{
click?: () => Promise<void>;
}>();
const loading = ref(false);
async function onClick() {
loading.value = true;
try {
if (props.click) {
await props.click();
}
} finally {
loading.value = false;
}
}
</script>