Breadcrumb 面包屑
WebH5
面包屑。展示当前页面在层级中的位置,items 驱动;支持外链 href 与路由路径 to(不集成 router,点击仅抛事件),最后一项为当前页。
何时使用
页面层级 ≥ 2 层,需要告知用户当前位置并支持向上回跳。
何时不使用
平级内容切换用 Tabs;只有一层结构时无需面包屑。
Props
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
items | Array<{ label: string; to?: string; href?: string }> | "[]" | 面包屑项;href 渲染为 <a> 外链,to 点击仅 emit item-click 由外部跳转,最后一项渲染为当前页文本 |
separator | string | "/" | 分隔符文本,可被 separator 插槽覆盖 |
Events
| 名称 | 载荷 | 说明 |
|---|---|---|
item-click | (item: BreadcrumbItem, index: number) | 点击非当前页项时触发,参数为该 item 与其下标 |
Slots
| 名称 | 说明 |
|---|---|
separator | 自定义分隔符内容,覆盖 separator prop |
示例
商城路径导航
示例加载中…
<Breadcrumb :items="[
{ label: '首页', to: '/' },
{ label: '数码家电', to: '/category/digital' },
{ label: '蓝牙耳机', to: '/category/digital/earphone' },
{ label: 'AirPods Pro 2 无线降噪款' },
]" @item-click="console.log('返回层:', $event.label)" />自定义分隔符
示例加载中…
<Breadcrumb separator=">" :items="[
{ label: '工作台', to: '/dashboard' },
{ label: '订单管理', to: '/orders' },
{ label: '订单详情' },
]" />外链跳转
示例加载中…
<Breadcrumb :items="[
{ label: '帮助中心', href: '#' },
{ label: '常见问题', href: '#' },
{ label: '如何申请退款' },
]" />自定义分隔符插槽
示例加载中…
<Breadcrumb :items="[
{ label: '首页', to: '/' },
{ label: '个人中心', to: '/account' },
{ label: '我的收藏' },
]">
<template #separator>
<span style="color:var(--rn-color-primary);font-size:12px">▶</span>
</template>
</Breadcrumb>事件监听
示例加载中…
<Breadcrumb @item-click="console.log('点击:', $event.label, '索引:', $index)" :items="[
{ label: '首页', to: '/' },
{ label: '订单列表', to: '/orders' },
{ label: '订单号 ORD-20260811-0037' },
]" />Playground
加载中…
跨端版本
该组件同时提供 uni-app / uni-app X 实现(H5 / 微信小程序 / App),API 可能略有差异,见 uni-app 端 Breadcrumb 文档(含手机预览)。