Antd-mobile uses Grid's walking lamp to slide and report errors from time to time.

with regard to a simple slider function, I don"t know how to solve this error. Google found that it seems to be related to the default event of the touch event, and no targeted solution has been found.

clipboard.png

clipboard.png

May.17,2022

there are two ways to solve this problem:
method one, CSS attribute: touch-action:none solves treated as passive error, acting on slider elements
this method has shortcomings:
(1). IOS Safari browser does not support;
(2). Kill the native touch-related behavior that may be needed
method 2: pass passive:false directly to solve the treated as passive error
problem code is:

document.addEventListener('touchmove', function (event) {
    event.preventDefault();
});

the fixed JavaScript code is:

document.addEventListener('touchmove', function (event) {
    event.preventDefault();
}, {
    passive: false
});

, that is, the third parameter of addEventListener passes passive:false, telling the browser that my event is not negative, and that Laozi took the initiative to do so. It's hard for the browser to say anything at this time, and then the code that we had a problem with before will work properly.

accidentally learned something about CSS touch-action. With touch-action:manipulation, we can safely use click events in our web pages.

Menu