feat: 按键事件处理 #190

Merged
lizhong merged 2 commits from fix/keyhandler into test 1 year ago
Collaborator
There is no content yet.
zhouxiaoan added 1 commit 1 year ago
lizhong reviewed 1 year ago
function onEsc(event) {
const eles = ['INPUT', 'TEXTAREA']
const keys = ['KeyC', 'KeyP', 'KeyX']
console.log(event.code)
lizhong commented 1 year ago
Owner

去一下log

去一下log
lizhong marked this conversation as resolved
lizhong reviewed 1 year ago
const passDialog = ref(false)
//
const rejectDialog = ref(false)
const rejectDialogCom = ref < (null)
lizhong commented 1 year ago
Owner

这个代码正常用嘛?

这个代码正常用嘛?
lizhong marked this conversation as resolved
lizhong reviewed 1 year ago
const rejectDialog = ref(false)
const rejectDialogCom = ref < (null)
//
const modal = useModal()
lizhong commented 1 year ago
Owner

这个声明没有看到哪里有使用,
如果没有 去一下
有的话 列举出来

这个声明没有看到哪里有使用, 如果没有 去一下 有的话 列举出来
lizhong marked this conversation as resolved
lizhong reviewed 1 year ago
const containerWidth = container.offsetWidth
const containerHeight = container.offsetHeight
const containerWidth = container?.offsetWidth
const containerHeight = container?.offsetHeight
lizhong commented 1 year ago
Owner

这两个声明有什么作用吗? 都没有被使用过

这两个声明有什么作用吗? 都没有被使用过
Poster
Collaborator

这是之前的代码,看逻辑是没用。

这是之前的代码,看逻辑是没用。
lizhong marked this conversation as resolved
lizhong reviewed 1 year ago
searchFixVal.value = ''
}
else {
emit('showDialog', val)
lizhong commented 1 year ago
Owner

看了一下代码,这个 emit 没有被声明

看了一下代码,这个 emit 没有被声明
lizhong marked this conversation as resolved
lizhong reviewed 1 year ago
function handleKeydown(event: KeyboardEvent) {
//
const eles = ['INPUT', 'TEXTAREA']
if (eles.includes(event?.target?.tagName))
lizhong commented 1 year ago
Owner

这里会提示
Vue: Property tagName does not exist on type EventTarget
chatgpt解释如下:
The error "Vue: Property 'tagName' does not exist on type 'EventTarget'" is occurring because TypeScript does not know that the EventTarget can be an Element, which has the tagName property. To fix this, you can use type assertion to tell TypeScript that the EventTarget is actually an Element. Here's how you can do it:
function handleKeydown(event: KeyboardEvent) {
// 排除元素
const eles = ['INPUT', 'TEXTAREA']
if (eles.includes((event.target as Element).tagName))
return
if (event.code === 'KeyC')
closeModal()
}
n this code, (event.target as Element).tagName tells TypeScript to treat event.target as an Element, which has the tagName property.

这里会提示 Vue: Property tagName does not exist on type EventTarget chatgpt解释如下: The error "Vue: Property 'tagName' does not exist on type 'EventTarget'" is occurring because TypeScript does not know that the EventTarget can be an Element, which has the tagName property. To fix this, you can use type assertion to tell TypeScript that the EventTarget is actually an Element. Here's how you can do it: function handleKeydown(event: KeyboardEvent) { // 排除元素 const eles = ['INPUT', 'TEXTAREA'] if (eles.includes((event.target as Element).tagName)) return if (event.code === 'KeyC') closeModal() } n this code, (event.target as Element).tagName tells TypeScript to treat event.target as an Element, which has the tagName property.
lizhong marked this conversation as resolved
zhouxiaoan added 1 commit 1 year ago
lizhong merged commit 848ecd9838 into test 1 year ago
lizhong deleted branch fix/keyhandler 1 year ago
The pull request has been merged as 848ecd9838.
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: guoxiangbin/ocr-web#190
Loading…
There is no content yet.