Cancel exiting page

Hello,
How can I cancel the exit from the page if, for example, there is unsaved data on it.

For example using route’s beforeLeave hook https://framework7.io/docs/routes.html#route-before-enter-leave

Thanks a lot. This works!