How to deal with vue when this.$router.go (- 1), it is judged that the keepAlive of the specified page is true? when it is returned to the specified page.

it is known that there is a page A, and this page has multiple pages that can be routed to jump over, such as: the BMagne C ~ (?) D page. Page A has a click event goIndex to return to the previous page. How to process and judge in page A that when the returned page is B, set the $route.meta.keepAlive of page B to true?
A page code as follows:

//
 goIndex(){
    this.$router.go(-1);
}

because the B page also has multiple entries, it may be returned from the A page, or it may be routed from the H page. Therefore, it cannot be set to meta: {keepAlive: true} directly in the index.js of the route.

so, how to set the keepAlive of the route to page B to true when page B is returned on page A?

Aug.24,2021

I think you can write it this way. Page B has a lot of entries, but page B knows which page came from
, so you can put it in the hook of page B:

.
 beforeRouteEnter (to, from, next) {
      next(vm => {
          if (from.path === '/A') {
              ...
              vm<=>this
          }
      })
    }
  

<template>
    <div style="height:100%">
    <!--  -->
      <keep-alive>
        <router-view v-if="$route.meta.keepAlive">
        </router-view>
      </keep-alive>
      <router-view v-if="!$route.meta.keepAlive"></router-view>
    </div>
</template>

//route.js
{
  path:"",
  name:"",
  component:A,
  meta: {
    keepAlive: false // 
  }
}

{
  path:"",
  name:"",
  component:B,
  meta: {
    keepAlive: true // 
  }
}

Brother, how did you solve the kneeling plea

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-1b3a4b6-2b97c.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-1b3a4b6-2b97c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?