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