How does vue get the path of a higher-level route

how do I get the path of a higher-level route path using this.$route.path, in vue?

Feb.16,2022

by upper-level route, do you mean the previous page route or the parent component route

if it is a higher-level route, you can listen to routing events and get

according to from.path.

if it is a parent component route, you need to write the parent component route to the mate parameter when defining the route, and then get

from the component according to the attribute.
{ 
      path: '/child', 
      name: 'child',
      component: Child,
      meta: {keepAlive: true, parentPath: 'parent}
}

let parentPath = this.$route.meta.parentPath
Menu