Could you tell me how to use vue dynamic routing?

I looked at the official document and I didn"t understand it. How should I write it in this.$router.push ("/ xx1/xx2")?


Feb.28,2021

this.$post () is related to your server routing, while your this.$router is the front-end route, and 404not found is your submission data route that does not match. Don't you separate the front and back ends?


although I still don't understand what you want to do. Two ways:

  1. one is component reuse, login is the superior route, there is only one empty router-view, with two child routes, and both tea and stu are equipped with login components as child routes.

    path: '/login',
    component: xxxx,
    children: [
        {
            path: 'teaxxxx',
            component: Login
        },
        {
            path: 'teaxxxx',
            component: Login
        }
    ]
  2. is using the params parameter (the document is written)

    {
        path: '/login/:type', 
        name: 'login'
        component: Login
    }

    use this.$route.params.type within login components to get type

at the same time, it is suggested that route redirection is not recommended. Path, recommends using name jump.

.push({name: 'login', params: {type: 'teaxxxx'}})
Menu