Files
heroui-vue/apps/docs/demos/toast-default.vue
T

31 lines
853 B
Vue

<script setup lang="ts">
import { onBeforeUnmount } from "vue";
import {
Button,
ToastProvider,
createToastFunction,
ToastQueue,
type ToastContentValue,
} from "@heroui-vue/components";
import { h } from "vue";
import { IconUsers } from "@tabler/icons-vue";
const queue = new ToastQueue<ToastContentValue>();
onBeforeUnmount(() => queue.destroy());
const toast = createToastFunction(queue);
function show() {
toast("您已被邀请加入团队", {
description: "Bob 邀请您加入 HeroUI 团队",
indicator: h(IconUsers),
actionProps: { label: "忽略", variant: "tertiary" },
});
}
</script>
<template>
<div class="flex h-full max-w-xl flex-col items-center justify-center">
<Button size="sm" variant="secondary" @click="show">显示 Toast</Button>
<ToastProvider :queue="queue" to="body" />
</div>
</template>