ActionBar
Combines icon entries, information and buttons in a bottom action bar with measured placeholder space.
Import
Use <hui-action-bar> after configuring uni-app easycom. Import public types and functions from @nscode/handy-uni. Ordinary Vue applications install the @nscode/handy-uni/web preview plugin.
Examples
Each example is standalone. Controls show the current value or event result on the page.
<template>
<view>
<hui-action-bar
:fixed="false"
:icons="icons"
:buttons="buttons"
@icon-click="(_, context) => (lastEvent = 'icon:' + context.index)"
@button-click="(_, context) => (lastEvent = 'button:' + context.index)"
>
<template #info><text>合计 / Total: 99</text></template>
<template #extra
><text>提交前请确认 / Review before submitting</text></template
> </hui-action-bar
><text>{{ lastEvent }}</text>
</view>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const lastEvent = ref('尚无事件 / No event')
const icons = [
{ icon: 'home', text: '首页 / Home' },
{ icon: 'star', text: '收藏 / Favorite', badge: 3 }
]
const buttons = [
{ text: '加入 / Add', type: 'warning' as const },
{ text: '购买 / Buy', type: 'primary' as const }
]
</script>
Props
| Prop | Type | Default | Details |
|---|---|---|---|
icons | ActionBarIcon[] | [] | Leading action entries. |
buttons | ActionBarButton[] | [] | Action-button entries. |
fixed | boolean | true | Fixes the bar to the viewport bottom. |
placeholder | boolean | true | Placeholder text or measured fixed-bar placeholder switch, depending on component. |
safeAreaInsetBottom | boolean | true | Adds bottom safe-area padding. |
border | boolean | true | Displays separators. |
buttonShape | 'round' | 'square' | 'round' | Rounded or square button-group edges. |
zIndex | number | 10 | Explicit stacking level. |
Root classes and styles use customClass and customStyle. Numbers representing dimensions use px; durations use ms unless explicitly documented.
Events
| Event | Arguments |
|---|---|
icon-click | (item: ActionBarIcon, context: { index:number }) |
button-click | (item: ActionBarButton, context: { index:number }) |
Controlled state only changes when the parent accepts its update event. Events with multiple words use kebab-case. Disabled or stale asynchronous actions do not emit a successful state change.
Slots
| Slot | Scope |
|---|---|
extra | — |
icon | { item, index } |
info | — |
button | { item, index } |
Methods
| Method | Signature | Description |
|---|---|---|
measure | (): Promise<void> | Measure layout again. |
Types
ActionBarIcon、ActionBarButton、ActionBarProps、ActionBarEmits、ActionBarExpose.
Platform notes
fixed and safeAreaInsetBottom are independent. Call measure after changing extra content. Loading buttons remain focusable but do not emit actions; disabled blocks interaction. openType only applies to WeChat and needs page sharing/contact setup. Verify fixed-bar behavior around software keyboards on each target.
Device smoke checklist.