修复input,number组件的lazy属性
parent
b303647129
commit
2f95f4f8b3
|
@ -472,7 +472,7 @@ export default class Input {
|
||||||
|
|
||||||
// 键盘事件
|
// 键盘事件
|
||||||
this._handleSubmit = $.catch(this.__INPUT__, 'keydown', ev => {
|
this._handleSubmit = $.catch(this.__INPUT__, 'keydown', ev => {
|
||||||
let { passwd, minlength } = this.props
|
let { passwd, minlength, lazy } = this.props
|
||||||
let val = this.value
|
let val = this.value
|
||||||
let now = Date.now()
|
let now = Date.now()
|
||||||
|
|
||||||
|
|
|
@ -218,7 +218,8 @@ export default class Number {
|
||||||
step: 1,
|
step: 1,
|
||||||
autofocus: false,
|
autofocus: false,
|
||||||
readonly: false,
|
readonly: false,
|
||||||
disabled: false
|
disabled: false,
|
||||||
|
lazy: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
__init__() {
|
__init__() {
|
||||||
|
@ -330,8 +331,13 @@ export default class Number {
|
||||||
}
|
}
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
|
this.stamp = 0
|
||||||
|
|
||||||
// 键盘事件
|
// 键盘事件
|
||||||
this._handleSubmit = $.catch(this.__INPUT__, 'keydown', ev => {
|
this._handleSubmit = $.catch(this.__INPUT__, 'keydown', ev => {
|
||||||
|
let now = Date.now()
|
||||||
|
let { lazy } = this.props
|
||||||
|
|
||||||
if (this.disabled || this.readOnly) {
|
if (this.disabled || this.readOnly) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -344,6 +350,14 @@ export default class Number {
|
||||||
// 回车触发submit事件
|
// 回车触发submit事件
|
||||||
if (ev.keyCode === 13) {
|
if (ev.keyCode === 13) {
|
||||||
ev.preventDefault()
|
ev.preventDefault()
|
||||||
|
|
||||||
|
// 并发拦截
|
||||||
|
if (lazy && now - this.stamp < lazy) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.stamp = now
|
||||||
|
|
||||||
this.dispatchEvent(
|
this.dispatchEvent(
|
||||||
new CustomEvent('submit', {
|
new CustomEvent('submit', {
|
||||||
detail: this.value
|
detail: this.value
|
||||||
|
@ -400,6 +414,10 @@ export default class Number {
|
||||||
this._checkActionEnable()
|
this._checkActionEnable()
|
||||||
break
|
break
|
||||||
|
|
||||||
|
case 'lazy':
|
||||||
|
this.props.lazy = val >> 0
|
||||||
|
break
|
||||||
|
|
||||||
case 'readonly':
|
case 'readonly':
|
||||||
case 'disabled':
|
case 'disabled':
|
||||||
var k = name
|
var k = name
|
||||||
|
|
Reference in New Issue