Skip to content

Navbar 自定义导航栏

页面顶部自定义导航栏,替代 uni-app 原生导航栏。支持返回按钮、标题居中、搜索栏嵌入、毛玻璃效果、安全区适配。

基础用法

vue
<template>
  <see-navbar title="页面标题" @on-back="onBack" />
</template>

搜索模式

vue
<template>
  <see-navbar :is-search="true" search-placeholder="搜索商品" @on-search="onSearch" />
</template>

毛玻璃效果

vue
<template>
  <see-navbar title="毛玻璃" :is-frosted="true" />
</template>

自定义插槽

vue
<template>
  <see-navbar>
    <template #left>
      <text>返回</text>
    </template>
    <template #center>
      <text>自定义标题</text>
    </template>
    <template #right>
      <text>设置</text>
    </template>
  </see-navbar>
</template>

自定义颜色

vue
<template>
  <see-navbar title="蓝色主题" bg-color="#3ca7ff" title-color="#ffffff" />
</template>

Props

属性类型默认值说明
titlestring''导航栏标题
isFixedbooleantrue是否固定在顶部
isShowLeftbooleantrue是否显示左侧区域
isShowRightbooleantrue是否显示右侧区域
leftTextstring''左侧文字
leftArrowbooleantrue左侧是否显示箭头
rightTextstring''右侧文字
rightIconstring''右侧图标名称
isSearchbooleanfalse是否为搜索模式
searchPlaceholderstring'搜索'搜索栏占位文字
isFrostedbooleanfalse是否启用毛玻璃效果
zIndexnumber990层级
safeAreaInsetTopbooleantrue是否适配顶部安全区
bgColorstring''自定义背景色
titleColorstring''自定义标题颜色
borderbooleantrue是否显示底部边框
placeholderbooleantruefixed 定位时是否生成占位元素

Events

事件名参数说明
onLeftClick-左侧按钮点击
onRightClickindex: number右侧按钮点击
onSearchquery: string搜索触发
onBack-返回按钮点击

Slots

插槽名说明
left左侧插槽
center中间插槽(覆盖 title)
right右侧插槽

Expose

方法名参数说明
setTitletitle: string动态设置标题
setRightTexttext: string动态设置右侧文字
show-显示导航栏
hide-隐藏导航栏

FAQ

如何在滚动时改变导航栏透明度?

可以通过监听页面滚动事件,动态修改 bgColor 属性来实现滚动透明度渐变效果。

毛玻璃效果在哪些平台生效?

毛玻璃效果使用 CSS backdrop-filter: blur(),在 H5 和 APP 端生效,小程序端可能不支持。

辽 ICP 备 2025070134 号