Skip to content

Popup

基础用法

html

<pa-cell-group inset>
  <pa-cell title="顶部弹出" is-link @click="onOpen('top')" />
  <pa-cell title="底部弹出" is-link @click="onOpen('bottom')" />
  <pa-cell title="左侧弹出" is-link @click="onOpen('left')" />
  <pa-cell title="右侧弹出" is-link @click="onOpen('right')" />
  <pa-cell title="中间弹出" is-link @click="onOpen('center')" />
</pa-cell-group>

<pa-popup v-model:show="visible" :position="position">
  <view style="width: 200px; height: 200px"></view>
</pa-popup>
ts

import { ref } from 'vue'
import type { PopupPosition } from '../..'

const visible = ref<boolean>(false)
const position = ref<PopupPosition>('bottom')

const onOpen = (_position: PopupPosition) => {
  position.value = _position
  visible.value = true
}

关闭按钮

html

<pa-cell-group inset>
  <pa-cell title="关闭按钮" is-link @click="onOpen()" />
</pa-cell-group>

<pa-popup v-model:show="visible" closeable>
  <view style="width: 200px; height: 200px"></view>
</pa-popup>
ts

import { ref } from 'vue'

const visible = ref<boolean>(false)

const onOpen = () => {
  visible.value = true
}

圆角弹窗

html

<pa-cell-group inset>
  <pa-cell title="圆角弹窗" is-link @click="onOpen()" />
</pa-cell-group>

<pa-popup v-model:show="visible" round>
  <view style="width: 200px; height: 200px"></view>
</pa-popup>
ts

import { ref } from 'vue'

const visible = ref<boolean>(false)

const onOpen = () => {
  visible.value = true
}
参数说明类型默认值
show是否显示booleanfalse
duration动画的执行时间,单位msstring | number300
zIndexz-index层级number999
position弹出方式PopupPosition'bottom'
overlay是否显示遮罩booleantrue
closeOnClickOverlay点击遮罩是否关闭弹窗booleantrue
width弹出宽度string-
height弹窗高度string-
bgColor背景色CSSProperties['background-color']-
round是否圆角boolean | string-
closeable是否显示关闭按钮boolean-
safeAreaInsetBottom是否适配底部安全区booleantrue
safeAreaInsetTop是否留出顶部安全距离(状态栏高度)boolean-
customClass自定义样式类string-
customStyle自定义弹出层样式CSSProperties-
contentClass内容自定义样式类string-
overlayStyle自定义遮罩层样式CSSProperties-
事件名参数
update:show(value: PopupProps['show'])
open()
opened()
close()
closed()
clickOverlay()
名称说明
default-

样式变量

名称默认值
--pa-popup-max-width100%
--pa-popup-background#fff
--pa-popup-radius0