vue js路由router传参

2018-12-18  本文已影响0人  奕格

1:通过路由配置

    this.$router.push({

        path:`/describe/${'222'}`

    })

    路由配置:

    {

        path:'/describe/:id',

          name:'Describe',

          component: Describe

     }

2:不跟在url后面 params传参

    this.$router.push({

        name:'Describe',

          params: {

            id:"hhhh"

          }

    })

    路由:

    {

        path:'/describe',

          name:'Describe',

          component: Describe

    }

    子组件获取方式::this.$route.params.id

3:跟在url后面 query传参

    this.$router.push({

        path:'/describe',

          query: {

            id:"ahaha"

          }

    })

    路由配置

    {

        path:'/describe',

          name:'Describe',

          component: Describe

    }

    子组件获取方式::this.$route.query.id

上一篇下一篇

猜你喜欢

热点阅读