1.新建公用文件:browserPatch.ts(可以是在common目录或者untils目录,根据自己的项目定)
;(function () {
if (typeof EventTarget !== 'undefined') {
const func = EventTarget.prototype.addEventListener
EventTarget.prototype.addEventListener = function (type, fn, capture) {
;(this as any).func = func
if (typeof capture !== 'boolean') {
capture = capture || {}
capture.passive = false
}
;(this as any).func(type, fn, capture)
}
}
})()
2.然后再在main.ts文件中,引入该文件:
import '@/utils/browserPatch'
|