修复input,number组件的lazy属性
parent
b303647129
commit
2f95f4f8b3
|
@ -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()
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Reference in New Issue