P
P
postya2020-08-22 18:39:13
Vue.js
postya, 2020-08-22 18:39:13

Why is the same parent component shown for a nested route?

There is a parent route that has a component
There is a nested route for it that has its own component

Why does a nested route show the same parent component and not its own?

if the nested route is made as an independent regular route, then everything works and its component is displayed, but for some reason it does not work with nested

Parent route:
5f413b486522c530652727.jpeg

Nested route:
5f413b6a7812c425486983.jpeg

index.js:

import Locations from "../views/Locations";
import PreviewLocation from "../components/PreviewLocation";

Vue.use(VueRouter);

const routes = [
{
    path: "/locations",
    name: "Locations",
    meta: {
      title: "Locations"
    },
    component: Locations,
    children: [
      {
        path: "archangel-falls",
        name: "Archangel Falls",
        component: PreviewLocation,
        meta: {
          title: "Archangel Falls"
        }
      }
    ]
  }
]

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes
});

router.beforeEach((to, from, next) => {
  document.title = to.meta.title;
  next();
});

export default router;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aetae, 2020-08-22
@postya

Because that's how it's meant to be. You can make nested chains router-view.
Read documentation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question