mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
feat(Popup): add closeable prop (#1964)
This commit is contained in:
parent
5c7b4fb4b3
commit
f6be2db496
@ -8,7 +8,8 @@ Page({
|
|||||||
bottom: false,
|
bottom: false,
|
||||||
left: false,
|
left: false,
|
||||||
right: false,
|
right: false,
|
||||||
round: false
|
round: false,
|
||||||
|
closeIcon: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -64,5 +65,13 @@ Page({
|
|||||||
|
|
||||||
hideRound() {
|
hideRound() {
|
||||||
this.toggle('round', false);
|
this.toggle('round', false);
|
||||||
|
},
|
||||||
|
|
||||||
|
showCloseIcon() {
|
||||||
|
this.toggle('closeIcon', true);
|
||||||
|
},
|
||||||
|
|
||||||
|
hideCloseIcon() {
|
||||||
|
this.toggle('closeIcon', false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -44,11 +44,24 @@
|
|||||||
/>
|
/>
|
||||||
</demo-block>
|
</demo-block>
|
||||||
|
|
||||||
|
<demo-block title="关闭图标" padding>
|
||||||
|
<van-button type="primary" bind:click="showCloseIcon">关闭图标</van-button>
|
||||||
|
|
||||||
|
<van-popup
|
||||||
|
show="{{ show.closeIcon }}"
|
||||||
|
closeable
|
||||||
|
position="bottom"
|
||||||
|
custom-style="height: 20%"
|
||||||
|
bind:close="hideCloseIcon"
|
||||||
|
/>
|
||||||
|
</demo-block>
|
||||||
|
|
||||||
<demo-block title="圆角弹窗" padding>
|
<demo-block title="圆角弹窗" padding>
|
||||||
<van-button type="primary" bind:click="showRound">圆角弹窗</van-button>
|
<van-button type="primary" bind:click="showRound">圆角弹窗</van-button>
|
||||||
|
|
||||||
<van-popup
|
<van-popup
|
||||||
show="{{ show.round }}"
|
show="{{ show.round }}"
|
||||||
|
round
|
||||||
position="bottom"
|
position="bottom"
|
||||||
custom-style="height: 20%"
|
custom-style="height: 20%"
|
||||||
bind:close="hideRound"
|
bind:close="hideRound"
|
||||||
|
@ -90,6 +90,10 @@
|
|||||||
|
|
||||||
// Popup
|
// Popup
|
||||||
@popup-round-border-radius: 12px;
|
@popup-round-border-radius: 12px;
|
||||||
|
@popup-close-icon-size: 18px;
|
||||||
|
@popup-close-icon-color: @gray-dark;
|
||||||
|
@popup-close-icon-margin: 16px;
|
||||||
|
@popup-close-icon-z-index: 1;
|
||||||
|
|
||||||
// Switch
|
// Switch
|
||||||
@switch-width: 2em;
|
@switch-width: 2em;
|
||||||
|
@ -84,6 +84,7 @@ Page({
|
|||||||
| custom-style | 自定义弹出层样式 | *string* | `` |
|
| custom-style | 自定义弹出层样式 | *string* | `` |
|
||||||
| overlay-style | 自定义背景蒙层样式 | *string* | `` |
|
| overlay-style | 自定义背景蒙层样式 | *string* | `` |
|
||||||
| close-on-click-overlay | 是否在点击遮罩层后关闭 | *boolean* | `true` |
|
| close-on-click-overlay | 是否在点击遮罩层后关闭 | *boolean* | `true` |
|
||||||
|
| closeable | 是否显示关闭图标 | *boolean* | `false` |
|
||||||
| safe-area-inset-bottom | 是否为 iPhoneX 留出底部安全距离 | *boolean* | `true` |
|
| safe-area-inset-bottom | 是否为 iPhoneX 留出底部安全距离 | *boolean* | `true` |
|
||||||
| safe-area-inset-top | 是否留出顶部安全距离(状态栏高度) | *boolean* | `false` |
|
| safe-area-inset-top | 是否留出顶部安全距离(状态栏高度) | *boolean* | `false` |
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"component": true,
|
"component": true,
|
||||||
"usingComponents": {
|
"usingComponents": {
|
||||||
|
"van-icon": "../icon/index",
|
||||||
"van-overlay": "../overlay/index"
|
"van-overlay": "../overlay/index"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,19 @@
|
|||||||
&--bottom&--safe {
|
&--bottom&--safe {
|
||||||
padding-bottom: @safe-area-inset-bottom;
|
padding-bottom: @safe-area-inset-bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__close-icon {
|
||||||
|
position: absolute;
|
||||||
|
top: @popup-close-icon-margin;
|
||||||
|
right: @popup-close-icon-margin;
|
||||||
|
z-index: @popup-close-icon-z-index;
|
||||||
|
color: @popup-close-icon-color;
|
||||||
|
font-size: @popup-close-icon-size;
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
opacity: .6;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.van-scale-enter-active,
|
.van-scale-enter-active,
|
||||||
|
@ -16,6 +16,7 @@ VantComponent({
|
|||||||
|
|
||||||
props: {
|
props: {
|
||||||
round: Boolean,
|
round: Boolean,
|
||||||
|
closeable: Boolean,
|
||||||
customStyle: String,
|
customStyle: String,
|
||||||
overlayStyle: String,
|
overlayStyle: String,
|
||||||
transition: {
|
transition: {
|
||||||
@ -46,6 +47,10 @@ VantComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
onClickCloseIcon() {
|
||||||
|
this.$emit('close');
|
||||||
|
},
|
||||||
|
|
||||||
onClickOverlay() {
|
onClickOverlay() {
|
||||||
this.$emit('click-overlay');
|
this.$emit('click-overlay');
|
||||||
|
|
||||||
|
@ -16,4 +16,10 @@
|
|||||||
bind:transitionend="onTransitionEnd"
|
bind:transitionend="onTransitionEnd"
|
||||||
>
|
>
|
||||||
<slot />
|
<slot />
|
||||||
|
<van-icon
|
||||||
|
wx:if="{{ closeable }}"
|
||||||
|
name="cross"
|
||||||
|
class="van-popup__close-icon"
|
||||||
|
bind:tap="onClickCloseIcon"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user