nwj-mm
 Box.addEventListener(\'mousedown\', function () {
                console.log(\'鼠标按下\')
            })
            Box.addEventListener(\'mousemove\', function () {
                console.log(\'鼠标移动\')
            })
            Box.addEventListener(\'mouseup\', function () {
                console.log(\'鼠标抬起\')
            })
 Box.addEventListener(\'touchstart\',function (){
                   console.log(\'手指按下\')
               })
               Box.addEventListener(\'touchmove\',function (){
                   console.log(\'手指移动\')
               })
               Box.addEventListener(\'touchend\',function (){
                   console.log(\'手指抬起\')
               })

touch 事件 和 mouse 事件的区别:

  • mousedown:鼠标按下 touchstart:手指触摸
  • mousemove:鼠标移动 touchmove:手指移动
  • moveup:鼠标抬起 touchend:手指抬起
  • touch事件只能在移动端使用;mouse事件只能在PC端使用;
  • touch事件的touchstart只能在元素内触发,touchmove和touchend可以在屏幕任意位置触发;
  • mouse事件都只能在元素内触发;
  • touch事件只有在touchstart触发后,才能触发touchmove和touchend事件;但mouse事件的mousemove只要在元素内没有鼠标按下也能触发

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-29
  • 2021-12-12
  • 2021-05-21
  • 2022-12-23
  • 2022-12-23
  • 2022-02-09
猜你喜欢
  • 2022-01-01
  • 2022-12-23
  • 2022-12-23
  • 2022-03-04
  • 2022-12-23
  • 2021-10-17
相关资源
相似解决方案