user23722952
user23722952

Reputation: 1

Using window.addEventListener beforeinstallprompt, it may occasionally not be triggered when the page is refreshed dozens of times。

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!

Upvotes: 0

Views: 151

Answers (0)

Related Questions