React中使用antd的select报错Unable to preventDefault inside passive event listener invocation.

夏兴平
2023-12-01

问题描述

报错Unable to preventDefault inside passive event listener invocation.

React中使用antd的select报错

Unable to preventDefault inside passive event listener invocation.`

解决方案1:

1卸载default-passive-events

但是此时会报警告useTouchMove.js:154 [Violation] Added non-passive event listener to a scroll-blocking ‘wheel’ event. Consider marking event handler as ‘passive’ to make the page more responsive.

解决方案2:

注释掉react-dom.development中的第6202行代码
文件路径:
node_modules/react-dom/cjs/react-dom.development.js

if (event.preventDefault) {
		//注释掉下面这行
        //event.preventDefault(); // $FlowFixMe - flow is not aware of `unknown` in IE
      } else if (typeof event.returnValue !== 'unknown') {
        event.returnValue = false;
      }

此时重启服务问题得到解决

 类似资料: