Files
timi-web/docs/demos/flower-fall/basic.vue
T
2026-09-21 15:32:12 +08:00

52 lines
1.1 KiB
Vue

<template>
<div class="demo">
<button
type="button"
class="btn"
@click="active = !active"
v-text="active ? '关闭落花背景' : '开启落花背景'"
/>
<p class="note" v-text="'组件本身是 fixed 全屏背景(z-index: -1),开启后花瓣会铺满整个视口并持续飘落。'" />
<b-e-flower-fall v-if="active" />
</div>
</template>
<script lang="ts" setup>
import { ref } from "vue";
import { BEFlowerFall } from "timi-web";
/**
* 落花按 document 尺寸计算飘落边界,因此适合作为整页背景。
* 这里用开关让它在真实形态下展示,而不是塞进小盒子里。
*/
const active = ref(false);
</script>
<style lang="less" scoped>
.demo {
.btn {
padding: .375rem .875rem;
font-size: .8125rem;
cursor: pointer;
border: 1px solid var(--vp-c-divider);
border-radius: .375rem;
color: var(--vp-c-text-1);
background: var(--vp-c-bg-soft);
&:hover {
color: var(--vp-c-brand-1);
border-color: var(--vp-c-brand-1);
}
}
.note {
margin: 1rem 0 0;
font-size: .75rem;
line-height: 1.6;
color: var(--vp-c-text-2);
}
}
</style>