Problem: the destroyed hook function is executed in the Vue sub component, but the instance is not destroyed to share the known contents: 1. The Vue project assumes that there is only Vue router, If you switch a sub component (specific Vue file) in the primary route, it will be destroyed in the Vue file. At this time, I think this sub component has destroyed the object of this sub component. 2. If you switch this sub component in each primary route, you will continue to create new this object and destroy this object
Experimental scenario: a simple Vue single page system of login and home page. The login page and home page switch in the primary route. I write the following code in the created hook function of the home page:
The timer will poll to get this object every other time. When I switch back and forth between login and home page, I will find that this timer prints out multiple this objects. Hehe, isn't it strange? Mingming was destroyed when switching, but why does the destroyed this object exist? What's wrong with that? That is to say, output the data attribute in the timer. When this attribute is initialized, it is a dynamically generated random number. You will find that the same attribute of this is composed of multiple contents....
There are also solutions, which can be called when switching back to login location.load To refresh, to clear.... But I really don't know what the principle is, which leads to the unexplained exception... Let me destroy the three outlooks, the dog