Navbar 导航条

自定义导航条组件,支持标题、左右文字/图标,可固定在顶部

自定义导航条组件,支持标题、左右文字/图标、显隐动画与固定吸顶。

演示

9:41

代码示例

<!-- 默认导航条 -->
  <re-navbar class="demo-default" title="标题" />

<!-- 带返回箭头的导航栏 -->
  <re-navbar class="demo-left-arrow" title="标题" :leftArrow="true" leftText="返回" />

<!-- 左侧图标 -->
  <re-navbar class="demo-left-icon" title="标题" leftIcon="close" />

<!-- 右侧图标 -->
  <re-navbar class="demo-right-icon" title="标题" rightIcon="ellipsis" />

<!-- 右侧文字+图标 -->
  <re-navbar class="demo-right-text-icon" title="标题" rightIcon="search" rightText="搜索" />

<!-- 左对齐标题 -->
  <re-navbar class="demo-left-align" title="左对齐标题" titleAlign="left" />

<!-- 标题省略 -->
  <re-navbar class="demo-title-ellipsis" title="这是一个超长标题演示文案" :titleMaxLength="6" />

<!-- 胶囊插槽 -->
  <re-navbar class="demo-capsule" title="标题" :leftArrow="true"> <template #capsule> <text class="demo-capsule__text">菜单</text> </template> </re-navbar>

<!-- 固定定位+占位 -->
  <re-navbar class="demo-fixed" title="固定导航" :fixed="true" :placeholder="true" customStyle="top: 24px; left: 16px; right: 16px; border-radius: 18px; box-shadow: 0 18px 44px rgba(15, 23, 42, 0.18);" />

<!-- 自定义样式 -->
  <re-navbar class="demo-custom-style" title="自定义" bgColor="#0052d9" titleColor="#ffffff" textColor="#ffffff" customStyle="border-bottom-width: 0px;" />

<!-- 无标题 -->
  <re-navbar class="demo-empty" leftText="返回" rightText="设置" />

<!-- 关闭安全区适配 -->
  <re-navbar class="demo-no-safe" title="无安全区" :safeAreaInsetTop="false" />

引入

推荐使用 easycom 模式,配置后无需手动 import 即可直接使用 <re-navbar />。

API

名称类型默认值描述必传
titlestring''标题N
leftTextstring''-N
rightTextstring''-N
fixedbooleanfalse-N
placeholderbooleanfalse占位提示文字N
safeAreaInsetTopbooleantrue-N
leftArrowbooleanfalse-N
leftIconstring''-N
rightIconstring''-N
titleAlign'center' | 'left''center'-N
customStylestring''自定义样式N
borderbooleantrue-N
bgColorstring'#ffffff'-N
titleColorstring'#181818'-N
textColorstring'#181818'-N
animationbooleantrue-N
deltanumber1-N
titleMaxLengthnumber0-N
visiblebooleantrue-N
zIndexnumber1层级N
名称参数描述
left-click-左侧点击时触发
right-click-右侧点击时触发
click-点击时触发
go-back--
faildetail: UTSJSONObject失败时触发
completedetail: UTSJSONObject-
successdetail: UTSJSONObject成功时触发
名称描述
left-
capsule-
title-
right-