Files
workspace/code/g3soft-libs/docs/examples/popover/controlled.vue
T
2026-10-08 22:38:34 +08:00

27 lines
845 B
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
// 受控用法:传 open 并监听 update:open,可做二次确认、埋点、权限拦截
import { ref } from 'vue'
import { G3Button, G3Message, G3Popover } from '@g3soft/ui'
const open = ref(false)
function onOpenChange(value: boolean) {
if (value) G3Message.info('打开前可以做权限校验/埋点')
open.value = value
}
</script>
<template>
<G3Popover :open="open" placement="bottom-start" @update:open="onOpenChange">
<template #trigger>
<G3Button type="outline">受控气泡</G3Button>
</template>
<template #content>
<div style="max-width: 200px">
<p style="margin: 0 0 8px">受控模式下,所有开关都经过 update:open。</p>
<G3Button size="small" @click="open = false">知道了</G3Button>
</div>
</template>
</G3Popover>
</template>