Appearance
xtf-bubble-menu-host
组件说明
xtf-bubble-menu-host 是气泡菜单宿主,用于为 BubbleMenu 提供定位、遮罩和传送目标。当前实现按源码声明的 props 渲染内容。
内部组件:由
xtf-bubble-menu组合使用,业务代码不应直接依赖其内部契约。
- 实际 Demo 路由:
#/pages/components/xtf-bubble-menu/index - Demo 源码
基础用法
1. 组合宿主与点击菜单
宿主包裹业务区域,BubbleMenu 负责触发和菜单状态。
vue
<template>
<XtfBubbleMenuHost>
<view class="host-basic"><XtfBubbleMenu :actions="actions" @select="onSelect"><view class="host-trigger"><text class="host-trigger-text">账单操作</text></view></XtfBubbleMenu></view>
</XtfBubbleMenuHost>
</template>
<script setup lang="uts">
import { ref } from "vue"
import XtfBubbleMenu from "@/uni_modules/xtf-linkuiunix/components/xtf-bubble-menu/xtf-bubble-menu.uvue"
import XtfBubbleMenuHost from "@/uni_modules/xtf-linkuiunix/components/xtf-bubble-menu-host/xtf-bubble-menu-host.uvue"
const actions = [{ key: 'edit', label: '编辑账单', icon: 'edit' }, { key: 'delete', label: '删除账单', icon: 'delete', danger: true }] as Array<any>
function onSelect(payload: any): void { console.log("选择操作", payload) }
</script>
<style>
.host-basic { display: flex; flex-direction: column; padding: 24rpx; }
.host-trigger { display: flex; flex-direction: row; padding: 20rpx; background-color: #ffffff; }
.host-trigger-text { color: #2563eb; font-size: 26rpx; }
</style>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2. 手动控制显示
手动模式通过 show 与 update:show 维护状态,宿主仍只负责定位。
vue
<template>
<XtfBubbleMenuHost>
<view class="host-controlled"><XtfBubbleMenu :show="visible" trigger="manual" :actions="actions" @update:show="visible = $event" @select="onSelect"><view class="host-trigger" @click="visible = !visible"><text class="host-trigger-text">切换菜单</text></view></XtfBubbleMenu></view>
</XtfBubbleMenuHost>
</template>
<script setup lang="uts">
import { ref } from "vue"
import XtfBubbleMenu from "@/uni_modules/xtf-linkuiunix/components/xtf-bubble-menu/xtf-bubble-menu.uvue"
import XtfBubbleMenuHost from "@/uni_modules/xtf-linkuiunix/components/xtf-bubble-menu-host/xtf-bubble-menu-host.uvue"
const actions = [{ key: 'edit', label: '编辑账单', icon: 'edit' }, { key: 'delete', label: '删除账单', icon: 'delete', danger: true }] as Array<any>
const visible = ref(false)
function onSelect(payload: any): void { console.log("手动菜单", payload) }
</script>
<style>
.host-controlled { display: flex; flex-direction: column; padding: 24rpx; }
.host-trigger { display: flex; flex-direction: row; padding: 20rpx; background-color: #ffffff; }
.host-trigger-text { color: #2563eb; font-size: 26rpx; }
</style>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
3. 组合自定义菜单项
自定义 item slot 仍由 BubbleMenu 提供 action 和 index。
vue
<template>
<XtfBubbleMenuHost>
<view class="host-slot"><XtfBubbleMenu :actions="actions" @select="onSelect"><view class="host-trigger"><text class="host-trigger-text">自定义菜单</text></view><template #item="scope"><text class="host-action">{{ scope.action.label }}</text></template></XtfBubbleMenu></view>
</XtfBubbleMenuHost>
</template>
<script setup lang="uts">
import { ref } from "vue"
import XtfBubbleMenu from "@/uni_modules/xtf-linkuiunix/components/xtf-bubble-menu/xtf-bubble-menu.uvue"
import XtfBubbleMenuHost from "@/uni_modules/xtf-linkuiunix/components/xtf-bubble-menu-host/xtf-bubble-menu-host.uvue"
const actions = [{ key: 'edit', label: '编辑账单', icon: 'edit' }, { key: 'delete', label: '删除账单', icon: 'delete', danger: true }] as Array<any>
function onSelect(payload: any): void { console.log("自定义菜单", payload) }
</script>
<style>
.host-slot { display: flex; flex-direction: column; padding: 24rpx; }
.host-trigger { display: flex; flex-direction: row; padding: 20rpx; background-color: #ffffff; }
.host-trigger-text { color: #2563eb; font-size: 26rpx; }
.host-action { color: #ffffff; font-size: 26rpx; }
</style>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
全部属性
| 属性 | 源码类型 | withDefaults 默认值 | 实际行为 / 范围 | 适用范围 |
|---|---|---|---|---|
| - | - | - | 当前组件未声明 props。 | - |
事件
| 事件名称 | 源码触发边界 | 回调参数 | 参数说明 |
|---|---|---|---|
| - | 当前组件未调用 defineEmits。 | - | - |
插槽
| 插槽 | Scope 参数 | 实际渲染位置 |
|---|---|---|
default | 无 scope 参数 | 仅在模板对应 <slot> 渲染位置生效。 |
方法
实例方法
| 方法 | 签名 / 返回值 | 调用边界 |
|---|---|---|
| - | - | 当前组件没有公开实例方法。 |
公开状态
| 状态 | 类型 / 包装 | 读取边界 |
|---|---|---|
| - | - | 当前组件没有公开状态。 |
主题说明
- 当前组件 CSS 未读取
var(--xtf-*)主题变量;颜色或尺寸可能来自 props、固定样式或父级上下文。
平台与实现边界
- 基线为 HBuilderX 5.26+ 与 uni-app x;当前报告已验证 Web Chromium 的对应 Demo,不据此承诺 Safari、小程序或 App 原生端等价。
- Android、iOS、HarmonyOS、Vapor 原生路径、触摸手势、字体、Canvas、安全区和系统权限能力,只有源码或完整性报告明确覆盖的部分才可视为已验证。
- 本文按当前源码生成,不补入旧版
xtf-linkui存在但迁移版未实现的 props、事件、slot 或方法。 - 详细公共边界见 平台与实现边界,逐项运行证据见项目根目录 COMPONENT_COMPLETENESS.md。