Using window.addEventListener beforeinstallprompt, after refreshing the page dozens of times, it may occasionally not be triggered. #744
Unanswered
LeslieZhang
asked this question in
Q&A
Replies: 1 comment
-
You can check the code we use in nuxt pwa integration here https://github.com/vite-pwa/nuxt/blob/main/src/runtime/plugins/pwa.client.ts#L86 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
My pwa project was successfully launched, using the following code:
window.addEventListener('beforeinstallprompt', e => { console.log('Show pwa button') state.buttonShow=true // The default value is false e.preventDefault() window.deferredPrompt = e })
I use this code to determine whether the pwa button is displayed。(The default value is false)
The development process went smoothly and there were no problems.
However, after going online, I found that in the window Google Chrome browser, I forced to refresh the page several times, and refreshed it dozens of times, and occasionally the button would not be displayed. The console did not print "Show pwa button".
So I think there is an occasional problem with the browser's monitoring? My project is vue3, and the above code is placed in app.vue.
I'd really appreciate if someone could answer this, thank you very much!
Beta Was this translation helpful? Give feedback.
All reactions