onclick and ontouchstart simultaneously

后端 未结 6 2002
花落未央
花落未央 2021-02-08 21:23

I have an ontouchstart event triggered on my mobile view, its linked to this:

function mobileLinksShow() {
    document.querySelector(\'.mobile-head         


        
6条回答
  •  天命终不由人
    2021-02-08 21:46

    Using e.preventDefault() for touch events is not working by default start from chrome 56.

    You can let it work manually by setting the { passive: false } option:

    document.querySelector('mobile-head-bar-left')
      .addEventListener(
        'touchstart',
        function(e) {
          // do something
          e.preventDefault()
        },
        { passive: false }
      )
    

提交回复
热议问题