Part of Android vue Jump to external Link Jump cannot be performed in the vue life cycle when jumping back from the external link

"/login"
beforeCreate: function() {
    alert("1")
},
created: function() {
   alert("2")
},
beforeMount: function() {
    alert("3")
},
mounted: function() {
    alert("4")
},
 methods: {
    login() {
       window.location.href=url
    }

}
enter the "/ login" route normally, the lifecycle function can execute alert normally
Click the login button to jump to the external url, get some information from the external url, and then jump back to the "/ login" route from the external url, the page will open normally, but all the lifecycle functions will fail, and the alert will not be executed. What is the reason


I also found this problem, and my solution is as follows:
add the following code to router.beforeEach to solve the problem that all hook functions that external links jump back to vue are unresponsive.

      let user = navigator.userAgent;
      let isAndroid = user.indexOf('Android') > -1 || user.indexOf('Adr') > -1; //android
      if (isAndroid) {
        let reloadTimes = sessionStorage.reloadTimes || 0;
        reloadTimesPP;
        sessionStorage.setItem('reloadTimes', reloadTimes);
        if (reloadTimes == 2) {
          router.go(0);
          return false;
        }
      }

rendered pages are not invalidated and lifecycle functions are no longer executed


you can use pageshow

window.addEventListener('pageshow', () => {
      ...
    })
Menu