Files
certd/packages/ui/certd-client/src/components/loading-button.vue
T

25 lines
411 B
Vue
Raw Normal View History

2024-11-30 01:57:09 +08:00
<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);
function onClick() {
loading.value = true;
try {
if (props.click) {
props.click();
}
} finally {
loading.value = false;
}
}
</script>