This repository has been archived on 2023-08-30. You can view files and clone it, but cannot push or open issues/pull-requests.
bytedo
/
wcui
Archived
1
0
Fork 0

修复input,number组件的lazy属性

old
宇天 2021-03-11 15:36:41 +08:00
parent b303647129
commit 2f95f4f8b3
2 changed files with 20 additions and 2 deletions

View File

@ -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()

View File

@ -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