From cb45acb2e249c42b196b2ceb7f98cb009cb0a997 Mon Sep 17 00:00:00 2001 From: yolo <1084677348@qq.com> Date: Tue, 5 Jan 2021 16:01:17 +0800 Subject: [PATCH 1/3] fix(verify-account-ui): Cannot read property 'focus' of undefined --- verify-account-ui/script.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/verify-account-ui/script.js b/verify-account-ui/script.js index 6df6bf0..4b7bfd4 100644 --- a/verify-account-ui/script.js +++ b/verify-account-ui/script.js @@ -1,4 +1,5 @@ const codes = document.querySelectorAll('.code') +const length = codes.length codes[0].focus() @@ -6,8 +7,14 @@ codes.forEach((code, idx) => { code.addEventListener('keydown', (e) => { if(e.key >= 0 && e.key <=9) { codes[idx].value = '' + if (length - 1 == idx) { + return + } setTimeout(() => codes[idx + 1].focus(), 10) } else if(e.key === 'Backspace') { + if (idx == 0) { + return + } setTimeout(() => codes[idx - 1].focus(), 10) } }) From d24b8bd9cf6f68dc94bf25b20ec29d7b56d9dc0e Mon Sep 17 00:00:00 2001 From: yolo <1084677348@qq.com> Date: Tue, 5 Jan 2021 16:05:06 +0800 Subject: [PATCH 2/3] Revert "fix(verify-account-ui): Cannot read property 'focus' of undefined" This reverts commit cb45acb2e249c42b196b2ceb7f98cb009cb0a997. --- verify-account-ui/script.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/verify-account-ui/script.js b/verify-account-ui/script.js index 4b7bfd4..6df6bf0 100644 --- a/verify-account-ui/script.js +++ b/verify-account-ui/script.js @@ -1,5 +1,4 @@ const codes = document.querySelectorAll('.code') -const length = codes.length codes[0].focus() @@ -7,14 +6,8 @@ codes.forEach((code, idx) => { code.addEventListener('keydown', (e) => { if(e.key >= 0 && e.key <=9) { codes[idx].value = '' - if (length - 1 == idx) { - return - } setTimeout(() => codes[idx + 1].focus(), 10) } else if(e.key === 'Backspace') { - if (idx == 0) { - return - } setTimeout(() => codes[idx - 1].focus(), 10) } }) From 47c916c27b2743651c2348c0d3d94d03be374d17 Mon Sep 17 00:00:00 2001 From: yolo <1084677348@qq.com> Date: Tue, 5 Jan 2021 16:09:50 +0800 Subject: [PATCH 3/3] fix(verify-account-ui): Cannot read property 'focus' of undefined --- verify-account-ui/script.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/verify-account-ui/script.js b/verify-account-ui/script.js index 6df6bf0..fe883d8 100644 --- a/verify-account-ui/script.js +++ b/verify-account-ui/script.js @@ -1,4 +1,5 @@ const codes = document.querySelectorAll('.code') +const length = codes.length codes[0].focus() @@ -6,8 +7,14 @@ codes.forEach((code, idx) => { code.addEventListener('keydown', (e) => { if(e.key >= 0 && e.key <=9) { codes[idx].value = '' + if(length - 1 == idx) { + return + } setTimeout(() => codes[idx + 1].focus(), 10) } else if(e.key === 'Backspace') { + if(idx == 0) { + return + } setTimeout(() => codes[idx - 1].focus(), 10) } })