Can it be triggered when routing a jump? I found that the function in beforeDestory was not triggered when I made a route jump, but there was a piece of code that needed to be executed before the component was destroyed. What should I do?
https://jsfiddle.net/44w37p34/ A friend just sent me a demo. I found that his beforeDestory was triggered when the route jumped, but mine never worked. What is the reason?
I found the reason. I added a keep-alive to the router-view before, causing the component to be cached, so beforeDestory and destoryed will not be triggered
I tried it, and it can trigger the execution of the beforeDestroy method when switching routes. The example is as follows.