Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

项目正常启动,但是控制台报addEventListener未定义 #2

Open
zhuminquan opened this issue Mar 8, 2020 · 5 comments
Open

Comments

@zhuminquan
Copy link

TypeError: Cannot read property 'addEventListener' of undefined
at VueComponent.created (ServiceWorkerUpdatePopup.vue?beb0:16)
at invokeWithErrorHandling (vue.runtime.esm.js?2b0e:1854)
at callHook (vue.runtime.esm.js?2b0e:4219)
at VueComponent.Vue._init (vue.runtime.esm.js?2b0e:5008)
at new VueComponent (vue.runtime.esm.js?2b0e:5154)
at createComponentInstanceForVnode (vue.runtime.esm.js?2b0e:3283)
at init (vue.runtime.esm.js?2b0e:3114)
at createComponent (vue.runtime.esm.js?2b0e:5978)
at createElm (vue.runtime.esm.js?2b0e:5925)
at createChildren (vue.runtime.esm.js?2b0e:6053)

@zandko
Copy link
Owner

zandko commented Mar 8, 2020

TypeError: Cannot read property 'addEventListener' of undefined
at VueComponent.created (ServiceWorkerUpdatePopup.vue?beb0:16)
at invokeWithErrorHandling (vue.runtime.esm.js?2b0e:1854)
at callHook (vue.runtime.esm.js?2b0e:4219)
at VueComponent.Vue._init (vue.runtime.esm.js?2b0e:5008)
at new VueComponent (vue.runtime.esm.js?2b0e:5154)
at createComponentInstanceForVnode (vue.runtime.esm.js?2b0e:3283)
at init (vue.runtime.esm.js?2b0e:3114)
at createComponent (vue.runtime.esm.js?2b0e:5978)
at createElm (vue.runtime.esm.js?2b0e:5925)
at createChildren (vue.runtime.esm.js?2b0e:6053)

我这边反复去校验并未复现,你这是项目一打开就出现吗

@zhuminquan
Copy link
Author

启动项目后报的错,偶发性的,有时候没有,很奇怪。ServiceWorkerUpdatePopup.vue中addEventListener未定义
created() {
// Listen for swUpdated event and display refresh notification as required.
document.addEventListener('swUpdated', this.showRefreshUI, { once: true })
// Refresh all open app tabs when a new service worker is installed.
navigator.serviceWorker.addEventListener('controllerchange', () => {
if (this.refreshing) return
this.refreshing = true
window.location.reload()
})
},

@zandko
Copy link
Owner

zandko commented Mar 12, 2020

启动项目后报的错,偶发性的,有时候没有,很奇怪。ServiceWorkerUpdatePopup.vue中addEventListener未定义
created() {
// Listen for swUpdated event and display refresh notification as required.
document.addEventListener('swUpdated', this.showRefreshUI, { once: true })
// Refresh all open app tabs when a new service worker is installed.
navigator.serviceWorker.addEventListener('controllerchange', () => {
if (this.refreshing) return
this.refreshing = true
window.location.reload()
})
},

这几天比较忙 忙完了这阵 我会继续更新的 到时候 把你遇到的这个问题给处理了

@zandko
Copy link
Owner

zandko commented Apr 19, 2020

启动项目后报的错,偶发性的,有时候没有,很奇怪。ServiceWorkerUpdatePopup.vue中addEventListener未定义
created() {
// Listen for swUpdated event and display refresh notification as required.
document.addEventListener('swUpdated', this.showRefreshUI, { once: true })
// Refresh all open app tabs when a new service worker is installed.
navigator.serviceWorker.addEventListener('controllerchange', () => {
if (this.refreshing) return
this.refreshing = true
window.location.reload()
})
}
已解决

@xayoung
Copy link

xayoung commented May 29, 2020

根据更新修改service-worker.js文件,还是报同样的错误,请问是什么问题呢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants