Skip to content

引入组件

局部引入

ts
const FBubblePopup = defineAsyncComponent(() => import('@/components/formaui/f-bubble-popup/f-bubble-popup.vue'))

基础用法

使用 v-model 控制显隐,默认插槽自定义气泡内容。点击遮罩关闭并触发 close 事件。

html
<f-button @click="show = true">打开气泡</f-button>
<f-bubble-popup
  v-model="show"
  top="280rpx"
  left="60rpx"
  triangle-direction="top"
  triangle-left="48rpx"
  triangle-top="-22rpx">
  <view>气泡内容</view>
</f-bubble-popup>

三角方向

triangleDirection属性:三角朝向,可选 top | bottom | left | right(默认top

配合 triangleLeft / triangleRight / triangleTop / triangleBottom 调整三角位置。

html
<f-bubble-popup
  v-model="show"
  bottom="320rpx"
  triangle-direction="bottom"
  triangle-left="48rpx"
  triangle-bottom="-22rpx">
  <view>内容</view>
</f-bubble-popup>

定位与样式

position属性:定位方式 relative | absolute | fixed(默认fixed

left / right / top / bottom / translateX / translateY:气泡位置

width / borderRadius / bgColor / textColor / boxShadow:尺寸与外观

html
<f-bubble-popup v-model="show" is-flex-end right="40rpx" top="200rpx" width="260rpx" bg-color="#5677fc">
  <view>右对齐气泡</view>
</f-bubble-popup>

遮罩

isMask属性:是否显示遮罩(默认true

maskColor属性:遮罩颜色(默认rgba(0, 0, 0, 0.4)

html
<f-bubble-popup v-model="show" :is-mask="false" top="200rpx" left="60rpx">
  <view>无遮罩</view>
</f-bubble-popup>

插槽

名称说明
default气泡内容

属性

属性名类型说明默认值
v-modelboolean是否显示false
widthstring宽度300rpx
borderRadiusstring圆角8rpx
leftstring定位 leftauto
rightstring定位 rightauto
topstring定位 topauto
bottomstring定位 bottomauto
translateXstring水平偏移0
translateYstring垂直偏移0
bgColorstring背景色#4c4c4c
textColorstring文字颜色#ffffff
triangleBorderWidthstring三角边宽12rpx
triangleDirection'top' | 'bottom' | 'left' | 'right'三角方向top
triangleLeftstring三角 leftauto
triangleRightstring三角 rightauto
triangleTopstring三角 topauto
triangleBottomstring三角 bottomauto
position'relative' | 'absolute' | 'fixed'定位方式fixed
isFlexEndboolean容器 flex-endfalse
isMaskboolean是否显示遮罩true
maskColorstring遮罩颜色rgba(0, 0, 0, 0.4)
boxShadowstring阴影''

事件

事件名说明回调参数
close点击遮罩关闭时-