ActionBar 动作栏

引入

通过以下方式来全局注册组件,更多注册方式请参考。

基础用法

  1. <van-action-bar-icon icon="chat-o" text="客服" @click="onClickIcon" />
  2. <van-action-bar-icon icon="cart-o" text="购物车" @click="onClickIcon" />
  3. <van-action-bar-icon icon="shop-o" text="店铺" @click="onClickIcon" />
  4. <van-action-bar-button type="danger" text="立即购买" @click="onClickButton" />
  5. </van-action-bar>

徽标提示

  1. <van-action-bar>
  2. <van-action-bar-icon icon="cart-o" text="购物车" badge="5" />
  3. <van-action-bar-icon icon="shop-o" text="店铺" badge="12" />
  4. <van-action-bar-button type="warning" text="加入购物车" />
  5. <van-action-bar-button type="danger" text="立即购买" />

通过 ActionBarIcon 的 color 属性可以自定义图标的颜色。

自定义按钮颜色

  1. <van-action-bar>
  2. <van-action-bar-icon icon="chat-o" text="客服" />
  3. <van-action-bar-icon icon="shop-o" text="店铺" />
  4. <van-action-bar-button color="#be99ff" type="warning" text="加入购物车" />
  5. <van-action-bar-button color="#7232dd" type="danger" text="立即购买" />
  6. </van-action-bar>

ActionBar Props

ActionBarIcon Props

参数说明类型默认值
text按钮文字string-
icon图标string-
color图标颜色string#323233
icon-class图标额外类名string | Array | object-
icon-prefix 图标类名前缀,等同于 Icon 组件的 class-prefix 属性stringvan-icon
dot是否显示图标右上角小红点booleanfalse
badge图标右上角徽标的内容number | string-
badge-props v3.2.8自定义徽标的属性,传入的对象会被透传给 BadgeProps-
url点击后跳转的链接地址string-
to点击后跳转的目标路由对象,等同于 vue-router 的 to 属性string | object-
replace是否在跳转时替换当前页面历史booleanfalse

ActionBarIcon Slots

名称说明
default文本内容
icon自定义图标

ActionBarButton Slots

类型定义

组件导出以下类型定义:

名称默认值描述
—van-action-bar-backgroundvar(—van-background-2)-
—van-action-bar-height50px-
—van-action-bar-icon-width48px-
—van-action-bar-icon-height100%-
—van-action-bar-icon-colorvar(—van-text-color)-
—van-action-bar-icon-size18px-
—van-action-bar-icon-font-sizevar(—van-font-size-xs)-
—van-action-bar-icon-active-colorvar(—van-active-color)-
—van-action-bar-icon-text-colorvar(—van-text-color)-
—van-action-bar-icon-backgroundvar(—van-background-2)-
—van-action-bar-button-height40px-
—van-action-bar-button-warning-colorvar(—van-gradient-orange)-
—van-action-bar-button-danger-colorvar(—van-gradient-red)-