Vue3解决element ui plus “Added non-passive event listener to a scroll-blocking ‘mousewheel‘ event.”

Posted woodwhale

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Vue3解决element ui plus “Added non-passive event listener to a scroll-blocking ‘mousewheel‘ event.”相关的知识,希望对你有一定的参考价值。

【Vue3】解决element ui plus “Added non-passive event listener to a scroll-blocking ‘mousewheel‘ event.”

如图,直接改element ui plus的源码

第一步:

import  isClient  from '@vueuse/core';

const isFirefox = () => isClient && /firefox/i.test(window.navigator.userAgent);
const isChrome = () => isClient && /chrome/i.test(window.navigator.userAgent);

export  isFirefox, isChrome ;
//# sourceMappingURL=browser.mjs.map

第二部:

import normalizeWheel from 'normalize-wheel-es';
import '../../utils/index.mjs';
import  isChrome, isFirefox  from '../../utils/browser.mjs';

const mousewheel = function(element, callback) 
  if (element && element.addEventListener) 
    const fn = function(event) 
      const normalized = normalizeWheel(event);
      callback && Reflect.apply(callback, this, [event, normalized]);
    ;
    if (isFirefox()) 
      element.addEventListener("DOMMouseScroll", fn);
     else if (isChrome()) 
      element.addEventListener("mousewheel", fn, passive: true)
     else 
      element.onmousewheel = fn;
    
  
;
const Mousewheel = 
  beforeMount(el, binding) 
    mousewheel(el, binding.value);
  
;

export  Mousewheel as default ;
//# sourceMappingURL=index.mjs.map

这样清爽多了,每次调试没黄色好看多了…

以上是关于Vue3解决element ui plus “Added non-passive event listener to a scroll-blocking ‘mousewheel‘ event.”的主要内容,如果未能解决你的问题,请参考以下文章

vue3.0安装element-ui的方式

Vue3经典UI框架Element Plus正式版发布啦!

vite vue3 引入 element-plus 报错

Vue3 UI组件库对比,Naive UIElement Plus Ant Design Vue

vue3+element-plus配置cdn

Vue3element ui plus面包屑与vue-route结合使用