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优化

old
宇天 2021-06-02 23:34:54 +08:00
parent 3072c972ce
commit c8078ddfc7
1 changed files with 7 additions and 5 deletions

View File

@ -488,7 +488,6 @@ export default class Input {
this._handleSubmit = $.catch(this.__INPUT__, 'keydown', ev => { this._handleSubmit = $.catch(this.__INPUT__, 'keydown', ev => {
let { minlength, lazy } = this.props let { minlength, lazy } = this.props
let val = this.value let val = this.value
let now = Date.now()
if (this.disabled || this.readOnly) { if (this.disabled || this.readOnly) {
return return
@ -500,13 +499,16 @@ export default class Input {
// 回车触发submit事件 // 回车触发submit事件
if (ev.keyCode === 13) { if (ev.keyCode === 13) {
ev.preventDefault()
let now = Date.now()
// 如果是输入建议存在,则第1次回车的时候, 不触发提交 // 如果是输入建议存在,则第1次回车的时候, 不触发提交
if (this.state.mvidx !== null) { if (this.state.mvidx !== null) {
return this._fetchSelect(this.state.mvidx, ev) return this._fetchSelect(this.state.mvidx, ev)
} }
// 并发拦截 // 并发拦截 intercept
if (lazy && now - this.stamp < lazy) { if (lazy && now - this.stamp < lazy) {
this.dispatchEvent(new CustomEvent('intercept'))
return return
} }
@ -557,9 +559,9 @@ export default class Input {
.join('') .join('')
this.__LIST__.firstElementChild.firstElementChild.innerHTML = html this.__LIST__.firstElementChild.firstElementChild.innerHTML = html
this.__LIST__.classList.toggle('show', true) this.__LIST__.classList.toggle('show', true)
this.__LIST__.style.cssText = `left:${x}px;top:${y + this.__LIST__.style.cssText = `left:${x}px;top:${
height + y + height + 5
5}px;width:${width}px;` }px;width:${width}px;`
} else { } else {
this.__LIST__.classList.toggle('show', false) this.__LIST__.classList.toggle('show', false)
} }