翻譯進行中
本頁尚未翻譯為繁體中文,以下顯示簡體中文原文。範例的預設元件文字仍使用繁體中文。
ActionBar 底部动作栏
固定底部动作栏,组合图标入口、信息和按钮组,自动留出等高占位。
引入
uni-app 配置 easycom 后使用 <hui-action-bar>。公开类型和函数从 @nscode/handy-uni 导入;普通 Vue 3 安装 @nscode/handy-uni/web 预览插件。
示例
示例可独立运行;交互结果直接显示在页面。
vue
<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
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
icons | ActionBarIcon[] | [] | 左侧图标入口 |
buttons | ActionBarButton[] | [] | 右侧按钮组 |
fixed | boolean | true | 固定在底部 |
placeholder | boolean | true | fixed 时在原位置留出等高占位,页面内容不被挡 |
safeAreaInsetBottom | boolean | true | 底部安全区 |
border | boolean | true | 上边细线 |
buttonShape | 'round' | 'square' | 'round' | 按钮组整体圆角还是直角 |
zIndex | number | 10 | 和 相关组件 TabBar 一致 |
根节点类名和样式使用 customClass、customStyle。尺寸数字按 px,时长除明确说明外按 ms。
Events
| 事件 | 参数 |
|---|---|
icon-click | (item: ActionBarIcon, context: { index:number }) |
button-click | (item: ActionBarButton, context: { index:number }) |
受控状态由父级回写更新事件后改变。多词事件使用短横线。禁用操作、取消及过期异步结果不提交成功变更。
Slots
| 插槽 | 作用域 |
|---|---|
extra | — |
icon | { item, index } |
info | — |
button | { item, index } |
方法
| 方法 | 签名 | 说明 |
|---|---|---|
measure | (): Promise<void> | 重新测量布局 |
类型
ActionBarIcon、ActionBarButton、ActionBarProps、ActionBarEmits、ActionBarExpose.
平台说明
fixed 与 safeAreaInsetBottom 独立。extra 内容变化后可调用 measure 更新占位。loading 按钮保留可聚焦但不触发事件;disabled 禁止交互。openType 仅微信有效,页面自行配置分享或客服;键盘顶起固定栏的行为需各端核对。
设备冒烟清单.