Mobile click event, sliding unavailable pit~~

Two days ago, I was trapped by a problem for an entire afternoon. To be precise, I was trapped by myself. The final result was very cliché and found the reason.despise

When debugging, in order to prohibit the sliding touch event of the page, I listened to the touchmove event, and then forgot to delete the sliding touch event after finding another way to prohibit the click event. then no thenTo shut up


It is also mentioned here that the click event of the general mobile page does not work, or the sliding does not work . Generally, check these two points, which can basically be solved:

1. Whether overflow: hidden is set on the root element of the page

2. Look at the touch event that disables the page:

touchstart (screen touch event) touchmove (screen sliding event) touchend (touch end)
//This is to prohibit sliding touch events
window.ontouchstart = function(e) { e.preventDefault(); };
document.addEventListener("touchmove", function(e){ e.preventDefault(); }, false);

Hereby to commemorate, a cool song for myself despise~~~

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324821135&siteId=291194637