37 lines
1.0 KiB
Vue
37 lines
1.0 KiB
Vue
<script setup lang="ts">
|
|
import { onBeforeUnmount } from "vue";
|
|
import {
|
|
Button,
|
|
ToastProvider,
|
|
ToastQueue,
|
|
createToastFunction,
|
|
} from "@heroui-vue/components";
|
|
const queue = new ToastQueue();
|
|
const toast = createToastFunction(queue);
|
|
onBeforeUnmount(() => queue.destroy());
|
|
</script>
|
|
<template>
|
|
<div class="flex h-full max-w-xl flex-wrap items-center justify-center gap-4">
|
|
<Button size="sm" variant="secondary" @click="toast('简单消息')">
|
|
默认
|
|
</Button>
|
|
<Button size="sm" variant="secondary" @click="toast.success('操作已完成')">
|
|
成功
|
|
</Button>
|
|
<Button size="sm" variant="secondary" @click="toast.info('有新更新可用')">
|
|
信息
|
|
</Button>
|
|
<Button
|
|
size="sm"
|
|
variant="secondary"
|
|
@click="toast.warning('请检查您的设置')"
|
|
>
|
|
警告
|
|
</Button>
|
|
<Button size="sm" variant="secondary" @click="toast.danger('出了点问题')">
|
|
错误
|
|
</Button>
|
|
<ToastProvider :queue="queue" to="body" />
|
|
</div>
|
|
</template>
|