From 413721bdfdf6415fb88af0378d55b00f075742b0 Mon Sep 17 00:00:00 2001 From: AhJindeg Date: Tue, 17 Dec 2024 16:30:58 +0800 Subject: [PATCH] fix: prevent default browser action for ctrl + k key combination in RouterSearch component MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 阻止 RouterSearch 组件中 ctrl + k 组合键的默认浏览器操作 --- src/components/RouterSearch/index.vue | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/RouterSearch/index.vue b/src/components/RouterSearch/index.vue index c0352422..a8f01ed9 100644 --- a/src/components/RouterSearch/index.vue +++ b/src/components/RouterSearch/index.vue @@ -98,6 +98,8 @@ onUnmounted(() => { // 监听 ctrl + k function listenKey(event) { if ((event.ctrlKey || event.metaKey) && event.key === 'k') { + // 阻止触发浏览器默认事件 + event.preventDefault() showSearch.value = !showSearch.value // 这里可以执行相应的操作(例如打开搜索框等) }