imherer
V2EX  ›  Vue.js

vueuse onKeyStroke Ignore Repeated Events 不生效

  •  
  •   imherer · Apr 17, 2024 · 986 views
    This topic created in 839 days ago, the information mentioned may be changed or developed.

    直接就是用的官网例子

    import { onKeyStroke } from '@vueuse/core'
    
    // use `autoRepeat` option
    onKeyStroke('A', (e) => {
      console.log('Key A pressed')
    }, { dedupe: true })
    

    是在 vueuse 官网的playground里试了是能正常生效的,但是在自己的项目里不生效,猜测原因可能是项目里用了 element plus 这个库,这个库引用了 9.13 版本的 vueuse ,而dedupe这个功能好像是 10.9 才有的,我在 package.json 里添加了 10.9 的 vueuse 还是不行

    前端大佬们这个应该怎么解决呢

    解决了:重新 run 了一下就生效了

    zcf0508
        1
    zcf0508  
       Apr 17, 2024
    给个最小复现
    imherer
        2
    imherer  
    OP
       Apr 17, 2024
    @zcf0508 谢谢

    解决了:pnpm 重新 run 了一下就生效了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2833 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 15:14 · PVG 23:14 · LAX 08:14 · JFK 11:14
    ♥ Do have faith in what you're doing.