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

80 lines
1.7 KiB
Vue

<template>
<div class="demo">
<div class="row">
<hover-popup value="组件形式的文本提示">
<span class="anchor" v-text="'悬停:纯文本'" />
</hover-popup>
<hover-popup :type="PopupType.IMG" :value="image">
<span class="anchor" v-text="'悬停:图片'" />
</hover-popup>
<hover-popup>
<span class="anchor" v-text="'悬停:自定义节点'" />
<template #popup>
<div class="card">
<strong v-text="'自定义浮层'" />
<p v-text="'浮层内容完全由插槽决定,可以是任意结构。'" />
</div>
</template>
</hover-popup>
</div>
<p class="note" v-text="'组件形式不需要注册全局指令,props 与 v-popup 指令的取值一致。'" />
<popup />
</div>
</template>
<script lang="ts" setup>
import { HoverPopup, Popup, PopupType } from "timi-web";
/**
* 演示用图片:内联 SVG,避免依赖外部图床。
*/
const image = `data:image/svg+xml;utf8,${encodeURIComponent(
`<svg xmlns="http://www.w3.org/2000/svg" width="180" height="80">` +
`<rect width="100%" height="100%" fill="#00a870"/>` +
`<text x="50%" y="50%" font-size="15" fill="#fff" text-anchor="middle" ` +
`dominant-baseline="central">HoverPopup</text></svg>`
)}`;
</script>
<style lang="less" scoped>
.demo {
.row {
display: flex;
flex-wrap: wrap;
gap: 1.5rem;
}
.anchor {
cursor: help;
border-bottom: 1px dashed var(--vp-c-brand-1);
color: var(--vp-c-brand-1);
}
.note {
margin: 1rem 0 0;
font-size: .75rem;
color: var(--vp-c-text-2);
}
.card {
padding: .5rem .75rem;
max-width: 16rem;
strong {
font-size: .8125rem;
}
p {
margin: .25rem 0 0;
font-size: .75rem;
line-height: 1.5;
color: #666;
}
}
}
</style>