Commit 413721bd by AhJindeg

fix: prevent default browser action for ctrl + k key combination in RouterSearch component

- 阻止 RouterSearch 组件中 ctrl + k 组合键的默认浏览器操作
parent 8362665f
...@@ -98,6 +98,8 @@ onUnmounted(() => { ...@@ -98,6 +98,8 @@ onUnmounted(() => {
// 监听 ctrl + k // 监听 ctrl + k
function listenKey(event) { function listenKey(event) {
if ((event.ctrlKey || event.metaKey) && event.key === 'k') { if ((event.ctrlKey || event.metaKey) && event.key === 'k') {
// 阻止触发浏览器默认事件
event.preventDefault()
showSearch.value = !showSearch.value showSearch.value = !showSearch.value
// 这里可以执行相应的操作(例如打开搜索框等) // 这里可以执行相应的操作(例如打开搜索框等)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment