用真实链接组织顶部导航和侧栏。items 提供名称与目标地址,分组通过 children 添加子导航。除“链接与新标签页”外,下列示例均在当前页演示,不离开文档。
横向面板与展开方式
trigger="click"(默认)通过点击展开,再次点击、外部点击或 Escape 关闭;鼠标移出不会关闭。trigger="hover" 通过悬停展开、移出延迟关闭,鼠标点击不反向切换;键盘和触屏仍可激活。
单列导航
panelLayout="list" 适合短链接。上方的 grid 示例适合带图标和说明的入口,宽度不足时自动转为单列。
纵向分组
设置 orientation="vertical" 就地展开分组。每个分组都能再次点击收起,defaultValue 指定初始展开项。
文档导航
收起为图标栏
collapsed 将纵向导航收起为图标栏。点击图标可打开侧向子导航,内部多层分组仍可收起;恢复侧栏时保留原展开状态。
tooltip 控制图标文字提示,默认开启。通过 leading 提供图标;没有图标时显示名称首字,完整名称仍可被读屏读取。
当前页与选中背景
currentKey 标记当前页,独立于分组展开。highlight 默认开启中性选中背景;设为 false 仅保留文字强调。hover、按下和展开不会把当前项的文字色改回普通色。
链接与新标签页
叶子使用 href 跳转;target="_blank" 在新标签页打开。分组按钮只展开子导航,分类首页应作为独立链接放入子项。
受控展开与路由
v-model:value 管理展开 key,currentKey 管理当前页面。接入客户端路由时通过 navigate 接收原始点击事件,保留修饰键和新标签页行为,并在跳转后安排页面焦点。
禁用与数据更新
disabled 禁用整组导航;条目的 disabled 禁用该分支。删除分组后自动清理失效展开值;无 href 的叶子显示为静态文字。
尺寸与插槽
size 只调整横向顶层控件。density="compact | regular" 单独控制子导航与纵向列表,默认 regular;不会随按钮一起放大面板。leading、trailing 用于图标和静态提示,不放嵌套按钮。
长内容与阅读方向
长名称自动换行,弹层超高时内部滚动。Locale Provider 设为 ar 等从右向左的语言时,布局和方向键操作同步翻转;侧栏分组可收起,避免长列表占满页面。
键盘操作
| 场景 | 操作 |
|---|---|
| 顶部入口 | 左右方向键移动;打开后 ArrowDown 进入子导航 |
| 图标栏入口 | 上下方向键移动;打开后 ArrowRight 进入(RTL 为 ArrowLeft) |
| 分组与链接 | Enter / Space 展开分组,Tab 移动,Enter 打开链接 |
| 弹层 | Escape 关闭并返回入口 |
API
QuireNavigationMenu Props
Slots 内容位置
leading标签前的静态图标。
{ /** Original entry. */ item: { /** Native URL; absent or empty values render a static span. */ href?: undefined | string; /** Native browsing context. */ target?: string | undefined; /** Native relationship; blank-window links default to noopener noreferrer. */ rel?: string | undefined; /** Links never simultaneously act as expansion triggers. */ children?: undefined; /** Stable key, unique throughout the whole tree. */ key: string; /** Visible accessible name. */ label: string; /** Supporting text, primarily useful inside panels. */ description?: string | undefined; /** Disables this entry and all of its descendants. */ disabled?: boolean | undefined; } | { /** Ordered destinations and nested categories. */ children: readonly (QuireKitNavigationMenuItem)[]; /** Put a category landing page in an explicit child link. */ href?: undefined; /** Stable key, unique throughout the whole tree. */ key: string; /** Visible accessible name. */ label: string; /** Supporting text, primarily useful inside panels. */ description?: string | undefined; /** Disables this entry and all of its descendants. */ disabled?: boolean | undefined; }; /** Whether the entry itself is the current destination. */ current: boolean; }trailing标签后的静态计数或提示。
{ /** Original entry. */ item: { /** Native URL; absent or empty values render a static span. */ href?: undefined | string; /** Native browsing context. */ target?: string | undefined; /** Native relationship; blank-window links default to noopener noreferrer. */ rel?: string | undefined; /** Links never simultaneously act as expansion triggers. */ children?: undefined; /** Stable key, unique throughout the whole tree. */ key: string; /** Visible accessible name. */ label: string; /** Supporting text, primarily useful inside panels. */ description?: string | undefined; /** Disables this entry and all of its descendants. */ disabled?: boolean | undefined; } | { /** Ordered destinations and nested categories. */ children: readonly (QuireKitNavigationMenuItem)[]; /** Put a category landing page in an explicit child link. */ href?: undefined; /** Stable key, unique throughout the whole tree. */ key: string; /** Visible accessible name. */ label: string; /** Supporting text, primarily useful inside panels. */ description?: string | undefined; /** Disables this entry and all of its descendants. */ disabled?: boolean | undefined; }; /** Whether the entry itself is the current destination. */ current: boolean; }
Events 组件事件
update:value更新
value,可通过对应 v-model 绑定。[value: string[] | undefined]navigate[item: QuireKitNavigationMenuLink, event: MouseEvent]