From c8078ddfc79ddb0e768857f2d8fcb9a7faa02f84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Wed, 2 Jun 2021 23:34:54 +0800 Subject: [PATCH] =?UTF-8?q?input=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/form/input.wc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/form/input.wc b/src/form/input.wc index b6091fd..b793260 100644 --- a/src/form/input.wc +++ b/src/form/input.wc @@ -488,7 +488,6 @@ export default class Input { this._handleSubmit = $.catch(this.__INPUT__, 'keydown', ev => { let { minlength, lazy } = this.props let val = this.value - let now = Date.now() if (this.disabled || this.readOnly) { return @@ -500,13 +499,16 @@ export default class Input { // 回车触发submit事件 if (ev.keyCode === 13) { + ev.preventDefault() + let now = Date.now() // 如果是输入建议存在,则第1次回车的时候, 不触发提交 if (this.state.mvidx !== null) { return this._fetchSelect(this.state.mvidx, ev) } - // 并发拦截 + // 并发拦截 intercept if (lazy && now - this.stamp < lazy) { + this.dispatchEvent(new CustomEvent('intercept')) return } @@ -557,9 +559,9 @@ export default class Input { .join('') this.__LIST__.firstElementChild.firstElementChild.innerHTML = html this.__LIST__.classList.toggle('show', true) - this.__LIST__.style.cssText = `left:${x}px;top:${y + - height + - 5}px;width:${width}px;` + this.__LIST__.style.cssText = `left:${x}px;top:${ + y + height + 5 + }px;width:${width}px;` } else { this.__LIST__.classList.toggle('show', false) }