How does vue make the page refresh only once?

after each login skip to the home page, part of the js becomes invalid. To solve this problem, I refresh the code once when I enter the home page as follows:

//home.vue
mounted:function(){
    location.reload()
}

but now the page is always refreshing the wireless loop, what if it is refreshed only once?


  1. Wireless refresh is because the component must enter the mounted hook after rendering, and then execute your reload, and then enter the hook, resulting in an endless loop.
  2. The state in the
  3. page is lost after the page is refreshed. So you can't use the status in the code to determine whether it has been refreshed before.
  4. if you need to refresh only once, you can save a state in the local store to determine. But I don't recommend it.
  5. as mentioned above, your problem is to solve the js failure, not to save the nation by studying to refresh the page.

there is something wrong with your problem. You should check why some of the js fails after skipping to the home page, rather than refreshing it directly.

The reason for the

infinite loop is that the hook function mounted executes when the component home.vue is added to the DOM, and your home page must use this component, so the loop is infinite.

or the first sentence, first find the real reason, solve it, do not want to bypass it.


determine whether the previous page is a login page, refresh it, or not refresh it

Menu