diff --git a/app/error.vue b/app/error.vue index 7a80080..2da691b 100644 --- a/app/error.vue +++ b/app/error.vue @@ -88,6 +88,14 @@ const handleBack = () => { // navigateTo(`${router.currentRoute.value.path}`) } +// 백스페이스 키 처리 +const handleKeydown = (e: KeyboardEvent) => { + if (e.key === 'Backspace' && + !['INPUT', 'TEXTAREA'].includes((e.target as HTMLElement).tagName)) { + e.preventDefault() + handleBack() + } +} // 500 에러 발생 시 /error 페이지로 리다이렉트 onMounted(() => { @@ -105,22 +113,14 @@ onMounted(() => { isLoading.value = false }) - // 백스페이스 키 처리 - const handleKeydown = (e: KeyboardEvent) => { - if (e.key === 'Backspace' && - !['INPUT', 'TEXTAREA'].includes((e.target as HTMLElement).tagName)) { - e.preventDefault() - handleBack() - } - } window.addEventListener('keydown', handleKeydown) window.addEventListener('popstate', handleBack) - onUnmounted(() => { - window.removeEventListener('keydown', handleKeydown) - window.removeEventListener('popstate', handleBack) - }) +}) +onUnmounted(() => { + window.removeEventListener('keydown', handleKeydown) + window.removeEventListener('popstate', handleBack) }) \ No newline at end of file