From 04bf6d78d44daa7968eae2a107da20037ba62ad4 Mon Sep 17 00:00:00 2001 From: 0xJacky Date: Sun, 13 Nov 2022 10:21:21 +0800 Subject: [PATCH] fix: log container not scroll to bottom --- frontend/src/views/nginx_log/NginxLog.vue | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/frontend/src/views/nginx_log/NginxLog.vue b/frontend/src/views/nginx_log/NginxLog.vue index 496c4dbd..cccc3f69 100644 --- a/frontend/src/views/nginx_log/NginxLog.vue +++ b/frontend/src/views/nginx_log/NginxLog.vue @@ -23,7 +23,7 @@ const control = reactive({ type: logType(), conf_name: route.query.conf_name, server_idx: parseInt(route.query.server_idx as string), - directive_idx: parseInt(route.query.directive_idx as string), + directive_idx: parseInt(route.query.directive_idx as string) }) function openWs() { @@ -51,11 +51,12 @@ function addLog(data: string, prepend: boolean = false) { } else { buffer.value += data } - - const elem = (logContainer.value as any as Element) - elem.scroll({ - top: elem.scrollHeight, - left: 0, + nextTick(() => { + const elem = (logContainer.value as any as Element) + elem?.scroll({ + top: elem.scrollHeight, + left: 0 + }) }) }