Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

99
Visualizações
How to ask user to confirm page refresh in vue3 composition API

I am new ti Vue and I am trying to get my app to ask the user for confimration before a page refresh (manual) can be done. IS this possible?

I know how to get the confirmation when the user clicks another router link.

I used the example here enter link description here to create this :

import { useRouter, onBeforeRouteLeave } from "vue-router";
    const promptExit = ref(true);
   onBeforeRouteLeave((to, from, next) => {
      if (promptExit.value) {
        const answer = window.confirm('Do you really want to leave? you have unsaved changes!')
  if (answer) {
    from()
  } else {
    from(false)
  }
      } else {
        next();
      }
    });

But is there a way to have the same effect on a hard page refresh on the browser

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda