Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
zhuà!
unidocs-zh
提交
32ade30c
unidocs-zh
项目概览
zhuà!
/
unidocs-zh
与 Fork 源项目一致
Fork自
DCloud / unidocs-zh
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
unidocs-zh
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
32ade30c
编写于
1月 30, 2024
作者:
H
HRK
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
新增 uni-popup新增属性:showClose
上级
e324f85c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
76 addition
and
74 deletion
+76
-74
docs/component/uniui/uni-popup.md
docs/component/uniui/uni-popup.md
+76
-74
未找到文件。
docs/component/uniui/uni-popup.md
浏览文件 @
32ade30c
# uni-popup 弹出层
::: tip 组件名:uni-popup
> 代码块: `uPopup`
> 关联组件:`uni-popup-dialog`,`uni-popup-message`,`uni-popup-share`,`uni-transition`
[
点击下载&安装
](
https://ext.dcloud.net.cn/plugin?name=uni-popup
)
:::
:::
弹出层组件,在应用中弹出一个消息提示窗口、提示框等
...
...
@@ -25,12 +26,12 @@
:::
### 基本用法
```
html
```
html
<template>
<view>
<button
@
click=
"open"
>
打开弹窗
</button>
<uni-popup
ref=
"popup"
type=
"bottom"
>
底部弹出 Popup
</uni-popup>
</view>
<view>
<button
@
click=
"open"
>
打开弹窗
</button>
<uni-popup
ref=
"popup"
type=
"bottom"
>
底部弹出 Popup
</uni-popup>
</view>
</template>
<script>
export
default
{
...
...
@@ -40,7 +41,7 @@ export default {
this
.
$refs
.
popup
.
open
(
'
top
'
)
}
}
}
}
</script>
```
...
...
@@ -51,7 +52,7 @@ export default {
而也有特例,需要我们主动去设置背景色,例如
`type = 'bottom'`
的时候 ,在异型屏中遇到了底部安全区问题(如 iphone 11),因为
`uni-popup`
的主要内容避开了安全区(设置
`safe-area:true`
),导致底部的颜色我们无法自定义,这时候使用
`background-color`
就可以解决这个问题。
**示例**
**
底部弹窗
示例**
```
html
<button
@
click=
"open"
>
打开弹窗
</button>
...
...
@@ -61,7 +62,7 @@ export default {
### 禁用打开动画
在某些场景 ,可能不希望弹层有动画效果 ,只需要将
`animation`
属性设置为
`false`
即可以关闭动画。
**示例**
**
居中弹窗
示例**
```
html
<button
@
click=
"open"
>
打开弹窗
</button>
...
...
@@ -235,6 +236,7 @@ export default {
|content|String|-|对话框内容,base模式下生效|
|confirmText
**[1.7.4新增]**
|String|-|定义确定按钮文本|
|cancelText
**[1.7.4新增]**
|String|-|定义取消按钮文本|
|showClose
**[1.8.5新增]**
|Boolean|-|是否显示取消按钮|
|value| String
\N
umber|-|输入框默认值,input模式下生效|
|placeholder|String|-|输入框提示文字,input模式下生效|
|before-close|Boolean|false | 是否拦截按钮事件,如为true,则不会关闭对话框,关闭需要手动执行 uni-popup 的 close 方法|
...
...
@@ -258,7 +260,7 @@ export default {
将
`uni-popup`
的
`type`
属性改为
`share`
,并引入对应组件即可使用 ,
*该组件不支持单独使用*
**示例**
#### 示例
```
html
<uni-popup
ref=
"popup"
type=
"share"
>
...
...
@@ -279,7 +281,7 @@ export default {
|:-:|:-:|:-:|
|select|选择触发|e = {item,index}:所选参数|
**Tips**
#### 注意
-
share 分享组件,只是作为一个扩展示例,如果需要修改数据源,请到组件内修改
...
...
@@ -327,64 +329,64 @@ export default {
```
**Tips**
#### tips
-
h5 滚动穿透不需要处理
-
wx、app 需要 使用 page-meta 组件配合阻止滚动穿透
-
注意 page-meta 组件,一个页面只能存在一个
-
其他平台无法阻止滚动穿透,建议使用 scroll-view 滚动 ,手动设置 overflow:hidden,同 page-meta 方法一致
##
示例
::: warning 注意
示例依赖了
`uni-card`
`uni-section`
`uni-scss`
等多个组件,直接拷贝示例代码将无法正常运行 。
请到
[
组件下载页面
](
https://ext.dcloud.net.cn/plugin?name=uni-popup
)
,在页面右侧选择
`使用 HBuilderX导入示例项目`
,体验完整组件示例。
:::
::: preview https://hellouniapp.dcloud.net.cn/pages/extUI/popup/popup
> Template
```
html
##
## 示例
::: warning 注意
示例依赖了
`uni-card`
`uni-section`
`uni-scss`
等多个组件,直接拷贝示例代码将无法正常运行 。
请到
[
组件下载页面
](
https://ext.dcloud.net.cn/plugin?name=uni-popup
)
,在页面右侧选择
`使用 HBuilderX导入示例项目`
,体验完整组件示例。
:::
::: preview https://hellouniapp.dcloud.net.cn/pages/extUI/popup/popup
> Template
```
html
<template>
<view
class=
"container"
>
<uni-card
is-full
:is-shadow=
"false"
>
<text
class=
"uni-h6"
>
弹出层组件用于弹出一个覆盖到页面上的内容,使用场景如:底部弹出分享弹窗、页面插屏广告等。
</text>
<view
class=
"container"
>
<uni-card
is-full
:is-shadow=
"false"
>
<text
class=
"uni-h6"
>
弹出层组件用于弹出一个覆盖到页面上的内容,使用场景如:底部弹出分享弹窗、页面插屏广告等。
</text>
</uni-card>
<uni-section
title=
"基本示例"
type=
"line"
>
<view
class=
"example-body box"
>
<button
class=
"button"
type=
"primary"
@
click=
"toggle('top')"
><text
class=
"button-text"
>
顶部
</text></button>
<button
class=
"button"
type=
"primary"
@
click=
"toggle('bottom')"
><text
class=
"button-text"
>
底部
</text></button>
<button
class=
"button"
type=
"primary"
@
click=
"toggle('center')"
><text
class=
"button-text"
>
居中
</text></button>
<button
class=
"button"
type=
"primary"
@
click=
"toggle('left')"
><text
class=
"button-text"
>
左侧
</text></button>
<button
class=
"button"
type=
"primary"
@
click=
"toggle('right')"
><text
class=
"button-text"
>
右侧
</text></button>
</view>
<uni-section
title=
"基本示例"
type=
"line"
>
<view
class=
"example-body box"
>
<button
class=
"button"
type=
"primary"
@
click=
"toggle('top')"
><text
class=
"button-text"
>
顶部
</text></button>
<button
class=
"button"
type=
"primary"
@
click=
"toggle('bottom')"
><text
class=
"button-text"
>
底部
</text></button>
<button
class=
"button"
type=
"primary"
@
click=
"toggle('center')"
><text
class=
"button-text"
>
居中
</text></button>
<button
class=
"button"
type=
"primary"
@
click=
"toggle('left')"
><text
class=
"button-text"
>
左侧
</text></button>
<button
class=
"button"
type=
"primary"
@
click=
"toggle('right')"
><text
class=
"button-text"
>
右侧
</text></button>
</view>
</uni-section>
<uni-section
title=
"提示消息"
type=
"line"
>
<view
class=
"example-body box"
>
<button
class=
"button popup-success"
@
click=
"messageToggle('success')"
><text
class=
"button-text success-text"
>
成功
</text></button>
<button
class=
"button popup-error"
@
click=
"messageToggle('error')"
><text
class=
"button-text error-text"
>
失败
</text></button>
<button
class=
"button popup-warn"
@
click=
"messageToggle('warn')"
><text
class=
"button-text warn-text"
>
警告
</text></button>
<button
class=
"button popup-info"
@
click=
"messageToggle('info')"
><text
class=
"button-text info-text"
>
信息
</text></button>
</view>
<uni-section
title=
"提示消息"
type=
"line"
>
<view
class=
"example-body box"
>
<button
class=
"button popup-success"
@
click=
"messageToggle('success')"
><text
class=
"button-text success-text"
>
成功
</text></button>
<button
class=
"button popup-error"
@
click=
"messageToggle('error')"
><text
class=
"button-text error-text"
>
失败
</text></button>
<button
class=
"button popup-warn"
@
click=
"messageToggle('warn')"
><text
class=
"button-text warn-text"
>
警告
</text></button>
<button
class=
"button popup-info"
@
click=
"messageToggle('info')"
><text
class=
"button-text info-text"
>
信息
</text></button>
</view>
</uni-section>
<uni-section
title=
"对话框示例"
type=
"line"
class=
"hideOnPc"
>
<view
class=
"example-body box"
>
<button
class=
"button popup-success"
@
click=
"dialogToggle('success')"
><text
class=
"button-text success-text"
>
成功
</text></button>
<button
class=
"button popup-error"
@
click=
"dialogToggle('error')"
><text
class=
"button-text error-text"
>
失败
</text></button>
<button
class=
"button popup-warn"
@
click=
"dialogToggle('warn')"
><text
class=
"button-text warn-text"
>
警告
</text></button>
<button
class=
"button popup-info"
@
click=
"dialogToggle('info')"
><text
class=
"button-text info-text"
>
信息
</text></button>
</view>
<uni-section
title=
"对话框示例"
type=
"line"
class=
"hideOnPc"
>
<view
class=
"example-body box"
>
<button
class=
"button popup-success"
@
click=
"dialogToggle('success')"
><text
class=
"button-text success-text"
>
成功
</text></button>
<button
class=
"button popup-error"
@
click=
"dialogToggle('error')"
><text
class=
"button-text error-text"
>
失败
</text></button>
<button
class=
"button popup-warn"
@
click=
"dialogToggle('warn')"
><text
class=
"button-text warn-text"
>
警告
</text></button>
<button
class=
"button popup-info"
@
click=
"dialogToggle('info')"
><text
class=
"button-text info-text"
>
信息
</text></button>
</view>
</uni-section>
<uni-section
title=
"输入框示例"
type=
"line"
padding
>
...
...
@@ -395,8 +397,8 @@ export default {
class=
"button-text"
>
输入对话框
</text></button>
</uni-section>
<uni-section
title=
"底部分享示例"
type=
"line"
padding
>
<button
class=
"button"
type=
"primary"
@
click=
"shareToggle"
><text
class=
"button-text"
>
分享模版示例
</text></button>
<uni-section
title=
"底部分享示例"
type=
"line"
padding
>
<button
class=
"button"
type=
"primary"
@
click=
"shareToggle"
><text
class=
"button-text"
>
分享模版示例
</text></button>
</uni-section>
<view>
<!-- 普通弹窗 -->
...
...
@@ -437,9 +439,9 @@ export default {
</view>
</view>
</template>
```
> Script
```
> Script
```
html
<script>
export
default
{
...
...
@@ -499,9 +501,9 @@ export default {
}
}
}
</script>
```
> Style
</script>
```
> Style
```
html
<style
lang=
"scss"
>
@mixin
flex
{
...
...
@@ -605,10 +607,10 @@ export default {
display
:
flex
;
/* #endif */
flex-direction
:
column
;
}
.dialog-box
{
padding
:
10px
;
}
.dialog-box
{
padding
:
10px
;
}
.dialog
.button
,
...
...
@@ -626,9 +628,9 @@ export default {
font-size
:
14px
;
color
:
#333
;
}
</style>
```
:::
</style>
```
:::
[
完整示例演示
](
https://hellouniapp.dcloud.net.cn/pages/extUI/popup/popup
)
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录