Skip to content

Navbar 导航栏

基础用法

html
<vz-navbar title="Navbar 导航栏"></vz-navbar>

右侧图标

html
<vz-navbar
  title="Navbar 导航栏"
  right-icon="iconfont icon-setup"
  :fixed="false"
  :safe-area-inset-top="false"
></vz-navbar>

两侧文字

html
<vz-navbar
  title="Navbar 导航栏"
  left-text="返回"
  right-text="设置"
  :fixed="false"
  :safe-area-inset-top="false"
></vz-navbar>

自定义颜色

html
<vz-navbar
  title="Navbar 导航栏"
  left-text="返回"
  right-icon="iconfont icon-setup"
  title-color="#ffffff"
  left-color="violet"
  right-color="teal"
  background="linear-gradient(to right, teal, violet)"
  :fixed="false"
  :safe-area-inset-top="false"
></vz-navbar>

插槽

html
<vz-navbar
  side-width="auto"
  :backable="false"
  :fixed="false"
  title-size="14px"
  :safe-area-inset-top="false"
  class="navbar"
  @left="handleClickLeft"
  @right="handleClickRight"
>
  <template #left>
    <view class="navbar_left">
      <text>郑州</text>
      <vz-icon name="vz-icon-arrow-bottom"></vz-icon>
    </view>
  </template>
  <view style="width: 100%">
    <vz-input
      placeholder="请输入"
      prefix-icon="vz-icon-search"
      height="30px"
      text-size="14px"
      background="var(--vz-bg-color-page)"
      round
    ></vz-input>
  </view>
  <template #right>
    <view class="navbar_right">
      <vz-icon name="iconfont icon-setup"></vz-icon>
    </view>
  </template>
</vz-navbar>

右侧无内容

html
<vz-navbar
  :backable="false"
  :right="false"
  :fixed="false"
  :safe-area-inset-top="false"
  class="navbar"
  @left="handleClickLeft"
>
  <template #left>
    <view class="navbar_left">
      <text>郑州</text>
      <vz-icon name="vz-icon-arrow-bottom"></vz-icon>
    </view>
  </template>
  <view style="width: 100%">
    <vz-input
      placeholder="请输入"
      prefix-icon="vz-icon-search"
      height="30px"
      text-size="14px"
      background="var(--vz-bg-color-page)"
      round
    ></vz-input>
  </view>
</vz-navbar>

Props

属性名说明类型默认值样式变量
fixed是否固定在顶部booleantrue-
z-indexz-indexstring / number--vz-z-index--vz-navbar-z-index
holder固定在顶部时,是否占位booleantrue-
px左右边距。默认单位 pxstring / number12px--vz-navbar-px
height导航栏高度(不包括状态栏高度)。默认单位 pxstring / number自动计算,不固定--vz-navbar-height
background背景。透明 transparentstring--vz-bg-color--vz-navbar-background
border是否显示显示下边框booleanfalse-
backable点击左侧按钮是否返回booleantrue-
title标题文字string--
title-size标题字体大小string16px--vz-navbar-title-size
title-color标题字体颜色string / numberinherit--vz-navbar-title-color
left是否显示左侧区域booleantrue-
left-icon左侧按钮图标stringvz-icon-arrow-left-
left-text左侧文案string--
left-color左侧字体颜色stringinherit--vz-navbar-left-color
right是否显示右侧区域booleantrue-
right-icon右侧按钮图标string--
right-text右侧文案string--
right-color右侧字体颜色stringinherit--vz-navbar-right-color
gap图标与文字之间的间距。默认单位 pxstring / number--vz-gap-base--vz-navbar-gap
side-width左右两侧宽度(自适应 auto)。默认单位 pxstring / number自动计算,不固定--vz-navbar-side-width
safe-area-inset-top是否开启顶部安全区适配booleantrue (WEB: false)-
status-bar是否显示占位状态栏(navbar 固定在顶部,且透明时可能会用到。需同时满足 fixed: true, safe-area-inset-top: true 时才生效)booleanfalse-
status-bar-fixed状态栏是否固定在顶部booleanfalse-
status-bar-bg背景status-bar--
i-class根节点样式类string--
i-style根节点样式Vue.StyleValue--

Events

事件名说明参数
loaded传递自动获取的参数{ height: string, sideWidth: string, statusBarHeight: string }
left点击左侧-
right点击右侧-
title点击中间-

Slots

插槽名说明
default中间内容
left左侧内容
right右侧内容

CSS

变量名描述默认值
--vz-navbar-left-size左侧字体大小inherit
--vz-navbar-right-size右侧字体大小inherit
--vz-navbar-border-color下边框--vz-border-color

SCSS

scss
$navbar: (
  "z-index": var(--vz-z-index),
  "px": 12px,
  "background": var(--vz-bg-color),
  "border-color": var(--vz-border-color),
  "text-size": 16px,
  "gap": var(--vz-gap-base),
);