Vue test error report

[Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive. See < URL >

the default within the passive event listener cannot be prevented because the target is considered passive.
see < URL >

I just clicked back and forth

Apr.11,2021

Chrome Dev Tools-Mobile


this is a warning and cannot use preventDefault for passive (passive) event listeners to block the default behavior


you go to know Passive Event Listeners.
Passive Event Listeners is a new browser feature proposed by Chrome: Web developers use a new attribute passive to tell the browser whether the preventDefault function will be called inside the event listeners registered on the current page to prevent the default behavior of events, so that browsers can make better decisions based on this information to optimize page performance. when the value of the attribute passive is true, the preventDefault function will not be called inside the listener to prevent the default sliding behavior . Chrome browsers call this type of listener passive (passive) listeners. Currently, Chrome mainly uses this feature to optimize page sliding performance, so the Passive Event Listeners feature currently supports only mousewheel/touch-related events.
this is probably because the touch event is triggered when you click on the page, while the default passive for the touch event is true, but the corresponding touch event uses preventDefault, so it triggers this error

solution reference: explicitly tell the browser that the passive of the corresponding event is false

el.addEventListener(
  'touchstart',
  fn,
  { passive: false }
);

I hope this article can help you
https://zhuanlan.zhihu.com/p/.

Menu