!623 fix: prevent default browser action for ctrl + k key combination in RouterSearch component
Merge pull request !623 from AhJindeg/fix/router-searchdev
commit
25484a941b
|
@ -99,6 +99,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
|
||||||
// 这里可以执行相应的操作(例如打开搜索框等)
|
// 这里可以执行相应的操作(例如打开搜索框等)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue