Vue: when to use @keyup.native in input elements

后端 未结 2 1994
别那么骄傲
别那么骄傲 2021-01-12 20:08

I have a Vue component with

  1. an element that binds the v-on:keyup.enter key to doFilter()
  2. a
2条回答
  •  时光说笑
    2021-01-12 21:00

    I had the same problem on a custom vue component on which I was listening to both @select and @keyup.native.enter and I was receiving the Enter key twice because I didn't pay attention: onSelect emits an onKeyDown for Enterand onkeyUp flared secondly.

    My solution was to listen to @keydown.native.enter so that the @select cycle of keys was unbothered (which is keydown -> keypresssed -> keyup).

提交回复
热议问题