diff --git a/src/form/input.wc b/src/form/input.wc index 4481b97..b77f2a3 100644 --- a/src/form/input.wc +++ b/src/form/input.wc @@ -472,7 +472,7 @@ export default class Input { // 键盘事件 this._handleSubmit = $.catch(this.__INPUT__, 'keydown', ev => { - let { passwd, minlength } = this.props + let { passwd, minlength, lazy } = this.props let val = this.value let now = Date.now() diff --git a/src/form/number.wc b/src/form/number.wc index b86409a..2c130c3 100644 --- a/src/form/number.wc +++ b/src/form/number.wc @@ -218,7 +218,8 @@ export default class Number { step: 1, autofocus: false, readonly: false, - disabled: false + disabled: false, + lazy: 0 } __init__() { @@ -330,8 +331,13 @@ export default class Number { } mounted() { + this.stamp = 0 + // 键盘事件 this._handleSubmit = $.catch(this.__INPUT__, 'keydown', ev => { + let now = Date.now() + let { lazy } = this.props + if (this.disabled || this.readOnly) { return } @@ -344,6 +350,14 @@ export default class Number { // 回车触发submit事件 if (ev.keyCode === 13) { ev.preventDefault() + + // 并发拦截 + if (lazy && now - this.stamp < lazy) { + return + } + + this.stamp = now + this.dispatchEvent( new CustomEvent('submit', { detail: this.value @@ -400,6 +414,10 @@ export default class Number { this._checkActionEnable() break + case 'lazy': + this.props.lazy = val >> 0 + break + case 'readonly': case 'disabled': var k = name