Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
monorepo
/
venus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit d5e0c173
authored
Mar 10, 2026
by
Lin
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat(popup): 自定义弹框
1 parent
828bc6e6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
116 additions
and
0 deletions
apps/uniappX/uniapp-x-tape/components/CustomPopup/README.md
apps/uniappX/uniapp-x-tape/components/CustomPopup/index.uvue
apps/uniappX/uniapp-x-tape/components/CustomPopup/README.md
0 → 100644
View file @
d5e0c17
# CustomPopup 公共弹窗组件
高度可配置的公共弹窗组件,支持多种定位模式、丰富的自定义选项及完善的交互体验。
## 过渡效果
-
**遮罩**
:淡入淡出
-
**居中弹窗**
:缩放 + 透明度(scale 0.9→1)
-
**底部/顶部弹窗**
:垂直滑入滑出
-
**左侧/右侧弹窗**
:水平滑入滑出
-
**时长**
:通过
`transitionDuration`
配置,默认 2000ms
## 使用方式
```
vue
<
template
>
<custom-popup
v-model:visible=
"showPopup"
position=
"center"
title=
"提示"
@
confirm=
"onConfirm"
@
cancel=
"onCancel"
>
<text>
弹窗内容
</text>
</custom-popup>
</
template
>
<
script
setup
lang=
"uts"
>
import
{
ref
}
from
'vue'
const
showPopup
=
ref
(
false
)
function
onConfirm
()
{
// 确认逻辑
}
function
onCancel
()
{
// 取消逻辑
}
</
script
>
```
## Props
| 属性 | 类型 | 默认值 | 说明 |
|------|------|--------|------|
| visible | boolean | false | 受控显示,支持 v-model:visible |
| position | 'center'
\|
'bottom'
\|
'top'
\|
'left'
\|
'right' | 'center' | 定位模式 |
| radiusPreset | 'sm'
\|
'md'
\|
'lg'
\|
'full' | 'md' | 圆角预设:小(4px)、中(8px)、大(12px)、全圆角 |
| borderRadius | string | - | 自定义圆角值,优先级高于 radiusPreset |
| bottomHeight | string | '50%' | 底部/顶部弹窗高度 |
| sideWidth | string | '80%' | 侧边弹窗宽度 |
| showMask | boolean | true | 是否显示遮罩 |
| maskClosable | boolean | true | 遮罩点击是否关闭 |
| maskOpacity | number | 0.5 | 遮罩透明度 |
| showHeader | boolean | true | 是否显示标题栏 |
| title | string | '' | 标题文本 |
| showClose | boolean | true | 是否显示关闭按钮 |
| closePosition | 'top-right'
\|
'top-left'
\|
'bottom-right'
\|
'bottom-left' | 'top-right' | 关闭按钮位置 |
| headerBorder | boolean | true | 标题栏底部分隔线 |
| showFooter | boolean | true | 是否显示底部按钮区 |
| showCancelBtn | boolean | true | 是否显示取消按钮 |
| cancelText | string | '取消' | 取消按钮文案 |
| confirmText | string | '确认' | 确认按钮文案 |
| confirmLoadingText | string | '加载中...' | 确认按钮加载中文案 |
| buttonOrder | 'cancel-first'
\|
'confirm-first' | 'cancel-first' | 按钮顺序 |
| confirmLoading | boolean | false | 确认按钮加载中 |
| confirmDisabled | boolean | false | 确认按钮禁用 |
| cancelDisabled | boolean | false | 取消按钮禁用 |
| customStyle | object | null | 自定义容器样式 |
| transitionDuration | number | 2000 | 过渡时长(毫秒),遮罩与容器的动画时长 |
## Slots
| 插槽名 | 说明 |
|--------|------|
| default | 主体内容 |
| header | 自定义标题栏,替换默认标题+关闭 |
| close-icon | 自定义关闭图标 |
| footer | 自定义底部区域,替换默认按钮组 |
## Events
| 事件 | 说明 |
|------|------|
| update:visible | v-model 同步 |
| close | 弹窗关闭时 |
| cancel | 点击取消按钮 |
| confirm | 点击确认按钮 |
## 方法(defineExpose)
| 方法 | 说明 |
|------|------|
| open() | 打开弹窗 |
| close() | 关闭弹窗 |
## CSS 变量(主题化)
父级可通过以下变量覆盖样式:
-
`--popup-primary-color`
主色
-
`--popup-border-radius`
圆角
-
`--popup-shadow`
阴影
-
`--popup-spacing`
间距
-
`--popup-font-size`
字体大小
-
`--popup-mask-color`
遮罩颜色
-
`--popup-mask-opacity`
遮罩透明度
## 结构类名
-
`.popup-mask`
遮罩层
-
`.popup-container`
弹窗容器
-
`.popup-header`
标题栏
-
`.popup-body`
内容区
-
`.popup-footer`
底部操作区
apps/uniappX/uniapp-x-tape/components/CustomPopup/index.uvue
0 → 100644
View file @
d5e0c17
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment