From 46a785705179b355373daf0c2b99af8bd32d1e0c Mon Sep 17 00:00:00 2001 From: qiang Date: Sat, 7 Nov 2020 18:11:58 +0800 Subject: [PATCH] =?UTF-8?q?feat(h5):=20=E6=97=A5=E6=9C=9F=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=20picker=20=E5=9C=A8=E6=A1=8C=E9=9D=A2=20Chrome?= =?UTF-8?q?=E3=80=81Firefox=20=E6=B5=8F=E8=A7=88=E5=99=A8=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E4=BD=BF=E7=94=A8=E7=B3=BB=E7=BB=9F=E6=97=A5=E5=8E=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../h5/view/components/picker/index.vue | 115 +++++++++++++----- 1 file changed, 82 insertions(+), 33 deletions(-) diff --git a/src/platforms/h5/view/components/picker/index.vue b/src/platforms/h5/view/components/picker/index.vue index e7e2c4fe2..a638af65a 100644 --- a/src/platforms/h5/view/components/picker/index.vue +++ b/src/platforms/h5/view/components/picker/index.vue @@ -19,9 +19,10 @@ />
+
+ +
= 0 + return Object.values(mode).includes(val) } }, fields: { type: String, - default: 'day', - validator (val) { - return Object.values(fields).indexOf(val) >= 0 - } + default: '' }, start: { type: String, @@ -234,7 +247,7 @@ export default { return [dateArray[0]] case fields.MONTH: return [dateArray[0], dateArray[1]] - case fields.DAY: + default: return [dateArray[0], dateArray[1], dateArray[2]] } } @@ -263,6 +276,16 @@ export default { return type } return String(navigator.vendor).indexOf('Apple') === 0 && navigator.maxTouchPoints > 0 ? selectorType.PICKER : selectorType.SELECT + }, + system () { + if (this.mode === mode.DATE && !Object.values(fields).includes(this.fields) && this.isDesktop && /win|mac/i.test(navigator.platform)) { + if (navigator.vendor === 'Google Inc.') { + return 'chrome' + } else if (/Firefox/.test(navigator.userAgent)) { + return 'firefox' + } + } + return '' } }, watch: { @@ -542,7 +565,15 @@ export default { value }) }, - _cancel () { + _cancel ($event) { + if (this.system === 'firefox') { + // Firefox 在 input 同位置区域点击无法隐藏控件 + const { top, left, width, height } = this.popover + const { pageX, pageY } = $event + if (pageX > left && pageX < left + width && pageY > top && pageY < top + height) { + return + } + } this._close() this.$trigger('cancel', {}, {}) }, @@ -559,6 +590,12 @@ export default { if (this.mode === mode.SELECTOR && this.selectorTypeComputed === selectorType.SELECT) { this.$refs.select.scrollTop = this.valueArray[0] * 34 } + }, + _input ($event) { + this.valueSync = $event.target.value + this.$nextTick(() => { + this._change() + }) } } } @@ -566,6 +603,7 @@ export default {