detach
Removes a handler or interceptor that was registered through on or intercept. Used for cleanup, typically on component teardown.
Usage
detach(tag: number | string | symbol): void;
| Argument | Type | Description |
|---|---|---|
tag | number | string | symbol | Tag returned (or supplied) when the handler was registered. |
Example
<script setup lang="ts">
import { ref, onUnmounted } from "vue";
import { Calendar } from "@wx/vue-calendar";
import type { CalendarInstanceApi } from "@wx/vue-calendar";
const api = ref<CalendarInstanceApi>();
const tag = Symbol("delete-guard");
function init(a: CalendarInstanceApi) {
api.value = a;
api.value.intercept(
"delete-event",
p => confirm(`Delete event ${p.id}?`),
{ tag }
);
}
onUnmounted(() => api.value?.detach(tag));
</script>
<template>
<Calendar :events="events" :init="init" />
</template>