mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-05-21 13:59:15 +08:00
feat(ActionSheet): add close-on-click-action prop (#1995)
This commit is contained in:
parent
bbd601168c
commit
fd82af0ac1
@ -1,4 +1,5 @@
|
||||
import Page from '../../common/page';
|
||||
|
||||
const format = rate => Math.min(Math.max(rate, 0), 100);
|
||||
|
||||
Page({
|
||||
|
@ -94,6 +94,7 @@ Page({
|
||||
| cancel-text | 取消按钮文字 | *string* | - | - |
|
||||
| overlay | 是否显示遮罩层 | *boolean* | - | - |
|
||||
| close-on-click-overlay | 点击遮罩是否关闭菜单 | *boolean* | - | - |
|
||||
| close-on-click-action | 是否在点击选项后关闭 | *boolean* | `true` | - |
|
||||
| safe-area-inset-bottom | 是否为 iPhoneX 留出底部安全距离 | *boolean* | `true` | - |
|
||||
|
||||
### Events
|
||||
|
@ -24,6 +24,10 @@ VantComponent({
|
||||
closeOnClickOverlay: {
|
||||
type: Boolean,
|
||||
value: true
|
||||
},
|
||||
closeOnClickAction: {
|
||||
type: Boolean,
|
||||
value: true
|
||||
}
|
||||
},
|
||||
|
||||
@ -33,6 +37,10 @@ VantComponent({
|
||||
const item = this.data.actions[index];
|
||||
if (item && !item.disabled && !item.loading) {
|
||||
this.$emit('select', item);
|
||||
|
||||
if (this.data.closeOnClickAction) {
|
||||
this.onClose();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -7,10 +7,10 @@
|
||||
|
||||
&__text {
|
||||
position: absolute;
|
||||
color: @circle-text-color;
|
||||
top: 50%;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
color: @circle-text-color;
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
}
|
||||
|
@ -57,9 +57,10 @@ VantComponent({
|
||||
|
||||
methods: {
|
||||
getContext() {
|
||||
return (
|
||||
this.ctx || (this.ctx = wx.createCanvasContext('van-circle', this))
|
||||
);
|
||||
if (this.ctx) {
|
||||
return this.ctx;
|
||||
}
|
||||
this.ctx = wx.createCanvasContext('van-circle', this);
|
||||
},
|
||||
|
||||
setHoverColor() {
|
||||
@ -71,9 +72,7 @@ VantComponent({
|
||||
const LinearColor = context.createLinearGradient(size, 0, 0, 0);
|
||||
Object.keys(color)
|
||||
.sort((a, b) => parseFloat(a) - parseFloat(b))
|
||||
.map(key => {
|
||||
LinearColor.addColorStop(parseFloat(key) / 100, color[key]);
|
||||
});
|
||||
.map(key => LinearColor.addColorStop(parseFloat(key) / 100, color[key]));
|
||||
hoverColor = LinearColor;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user