M
M
midiks12019-10-23 16:26:22
Vue.js
midiks1, 2019-10-23 16:26:22

How to implement VueJs child routing?

There is such a routing

{
    path: "/user/:id",
    component: User,
    children: [{
        path: "profile",
        name: "profile",
        component: Profile
    },
    {
        path: "articles",
        name: "articles"
        component: Articles
    }]
}

Inside the User component ( parent ) I have basic information about the user loaded in created
Inside Articles , Profile information is already loaded for each component separately (also in created )
When I do router.push({ name: "articles", id: 1 } ) , then everything is ok: the User component loads the basic information, and the Articles component loads the user's articles, but when I do router.push({ name: "articles", id: 2 }) , the User works great, but the Articles leaves the user's articles 1 (it is not updated, i.e. createddoes not work with loading and data from the last linking is saved)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
midiks1, 2019-10-23
@midiks1

The most humane way to get around this problem is to use the key for the router-view,
namely the router-view in the User component.
you can also add watch to the id parameter, but there will be problems with this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question