Files
heroui-vue/apps/docs/demos/dropdown-controlled-open-state.vue
maoyingjie 06ddb6662a feat: migrate Menu and Dropdown with selection and submenus
Port HeroUI menu family and Dropdown from ce90ea3: Reka DropdownMenu base,
MenuKey[] selection with section owners, 17 official demos, dropdown docs
and B01 tests. Long-press stays demo-level; submenu close is level-scoped.
2026-10-24 20:43:04 +08:00

44 lines
1.3 KiB
Vue
Raw Permalink 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">
import { ref } from "vue";
import {
DropdownRoot,
DropdownTrigger,
DropdownPopover,
DropdownMenu,
DropdownItem,
Button,
Label,
} from "@heroui-vue/components";
const open = ref(false);
</script>
<template>
<div class="flex min-w-sm flex-col items-center justify-center gap-4">
<p class="text-sm text-muted">
下拉菜单:
<strong>{{ open ? "打开" : "关闭" }}</strong>
</p>
<DropdownRoot v-model:open="open">
<DropdownTrigger>
<Button aria-label="菜单" variant="secondary">操作</Button>
</DropdownTrigger>
<DropdownPopover>
<DropdownMenu>
<DropdownItem id="new-file" text-value="新建文件">
<Label>新建文件</Label>
</DropdownItem>
<DropdownItem id="open-file" text-value="打开文件">
<Label>打开文件</Label>
</DropdownItem>
<DropdownItem id="save-file" text-value="保存文件">
<Label>保存文件</Label>
</DropdownItem>
<DropdownItem id="delete-file" text-value="删除文件" variant="danger">
<Label>删除文件</Label>
</DropdownItem>
</DropdownMenu>
</DropdownPopover>
</DropdownRoot>
</div>
</template>