The problem of returning to the previous page after the Vue route is redirected

In the

Vue project, there are four pages, namely index entry file, AMagneBMagi C, in which all of them use history.go (- 1) to return the previous page, and
their jump relationship is

.

index "A" B "C, in which there is a jump button on the C page to jump to the A page. Now we hope that after jumping from the C page to the A page, we can no longer return C through the return button on the A page, but return index,. Their final jump relationship is

.

index / A / B / C / A / An index

the current jump code is as follows, but the A page always returns C:

index: $router.push ({name:"A"})
A: $router.push ({name:"B"})
B: $router.push ({name:"C"})
C: $router.replace ({name:"A"})

how should this demand jump be realized?

Dec.08,2021

you can use the routing hook beforeRouteLeave, to specify where to jump when leaving the A page


if A cannot jump directly to C
, you can use beforeRouteLeave on page A to determine your destination page, and if it is C, force to jump to index

.
 beforeRouteLeave(to, from, next){
    if(to.name == "C"){
      this.$router.push({name:"index"});
    }else{
      next();
    }
  },
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3eb59-4dad2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3eb59-4dad2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?