Understand this question is quite old but if I'm out there searching for it, someone else is!
Unfortunately, as far I can tell there is nothing in Vue that can currently hook into before the user reloads the page either via closing, CMD+R, selecting a new URL etc.
The best solution, if it's sensitive data and you really want them to think about what they are doing, you can do the below which is taken from this medium post.
<script>
export default {
data: () => ({
isEditing: false
})
beforeMount() {
window.addEventListener("beforeunload", this.preventNav)
},
methods: {
preventNav(event) {
if (!this.isEditing) return
event.preventDefault()
event.returnValue = ""
}
}
}
</script>
This will at least bring up a dialogue box asking if they are really sure they want to reload the page.
Note the text of the dialogue box cannot be altered. A good description of what is going on with the dialogue box text is contained in this StackOverflow question.