Dynamic route mapping is specifically designed so that different routes or URLs map to the same route or component. Therefore, changing the argument is technically not considered a departure (or change) of the route, therefore beforeRouteLeave does not work.
However , I suggest that you can execute the component that matches the route responsible for detecting changes in the argument. Basically, whenever an argument changes, write down the change and then change it (we hope that the reversal will be fast enough so that the user goes unnoticed), and then ask for confirmation. If the user confirms the change, then use your entry to "cancel" the change, but if the user does not confirm, then save everything as it is (do not change the opposite).
I have not tested this personally, and therefore I canβt guarantee it will work, but I hope it would eliminate any confusion as to which part of the application is responsible for checking which changes.
source share