Skip to content

Commit

Permalink
fix(输入框高亮): 切换车牌类型时,不保留最后一位车牌号
Browse files Browse the repository at this point in the history
  • Loading branch information
liaoyinglong committed Apr 11, 2018
1 parent c9b280c commit 348465c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export default class plateNumberInput {
this.options = Object.assign(defaultOptions, options);
this.el = document.querySelector(this.options.el);
this.currentIndex = 0;
this.prevIndex = 0;
this.containerInput = null;
this.spareSpan = null;
this.isNewpower = this.options.isNewpower;
Expand Down Expand Up @@ -71,6 +70,7 @@ export default class plateNumberInput {
setNumberType(isNewpower = false) {
this.isNewpower = isNewpower;
const lastIndex = this.inputSpans.length - 1;
this.spareSpan.innerText = ''
if (!this.spareSpan.parentNode && isNewpower) {
this.containerInput.appendChild(this.spareSpan);
}
Expand Down Expand Up @@ -210,10 +210,11 @@ export default class plateNumberInput {
*/
setInputFocus(index = 0) {
this.keyboardWrapper.classList.remove('hide');
this.prevIndex = this.currentIndex || 0;
this.currentIndex = index;
this.inputSpans[this.prevIndex] && this.inputSpans[this.prevIndex].classList.remove('focus');
this.inputSpans[this.currentIndex] && this.inputSpans[this.currentIndex].classList.add('focus');
for (let i = 0; i < this.inputSpans.length; i++) {
this.inputSpans[i].classList.remove('focus');
}
this.currentIndex = index;
this.inputSpans[index].classList.add('focus');
this._generateKeyboard();
this.setBtnSaveActive();
}
Expand Down

0 comments on commit 348465c

Please sign in to comment.