diff --git a/example/pages/circle/index.js b/example/pages/circle/index.js index 1828d203..43a23e63 100644 --- a/example/pages/circle/index.js +++ b/example/pages/circle/index.js @@ -1,4 +1,5 @@ import Page from '../../common/page'; + const format = rate => Math.min(Math.max(rate, 0), 100); Page({ diff --git a/packages/action-sheet/README.md b/packages/action-sheet/README.md index e7af1bbc..d0acbc9b 100644 --- a/packages/action-sheet/README.md +++ b/packages/action-sheet/README.md @@ -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 diff --git a/packages/action-sheet/index.ts b/packages/action-sheet/index.ts index 0ddbf6d6..c0d2c708 100644 --- a/packages/action-sheet/index.ts +++ b/packages/action-sheet/index.ts @@ -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(); + } } }, diff --git a/packages/circle/index.less b/packages/circle/index.less index c2c94847..79f7dea1 100644 --- a/packages/circle/index.less +++ b/packages/circle/index.less @@ -7,10 +7,10 @@ &__text { position: absolute; - color: @circle-text-color; top: 50%; left: 0; width: 100%; + color: @circle-text-color; transform: translateY(-50%); } } diff --git a/packages/circle/index.ts b/packages/circle/index.ts index 08a859b5..fd71c529 100644 --- a/packages/circle/index.ts +++ b/packages/circle/index.ts @@ -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; }