H5长按事件

 1 let timeOutEvent = 0
 2 $(function () {
 3   $('#debug').on({
 4     touchstart: function (e) {
 5       setTimeout(function () {
 6         longPress()
 7       }, 10000)
 8       e.preventDefault()
 9     },
10     touchmove: function () {
11       clearTimeout(timeOutEvent)
12       timeOutEvent = 0
13     },
14     touchend: function () {
15       clearTimeout(timeOutEvent)
16       return false
17     }
18   })
19 })
20 
21 /* eslint-disable no-unused-vars */
22 function longPress () {
23   timeOutEvent = 0
24   router.go('about')
25 }

 

你可能感兴趣的:(H5长按事件)