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