事件起因:在微应用点击其他微应用的页面后,回到自己项目导致antd datepicker选择时间无法选中。控制台报错:Unable to preventDefault inside passive event listener invocation,这个警告通常出现在使用passive事件监听器时,当在事件处理函数中调用preventDefault()方法时会引发该警告
解决方案:
在main.js中(或新建js文件,引入到main.js中),重写addEventListener,把passive置为false;
(function () {
if (typeof EventTarget !== "undefined") {
const func = EventTarget.prototype.addEventListener;
EventTarget.prototype.addEventListener = function (type, fn, capture) {
this.func = func;
if (typeof capture !== "boolean") {
capture = capture || {};
capture.passive = false;
}
this.func(type, fn, capture);
};
}
})();