美文网首页
vue js路由router传参

vue js路由router传参

作者: 奕格 | 来源:发表于2018-12-18 14:08 被阅读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

    相关文章

      网友评论

          本文标题:vue js路由router传参

          本文链接:https://www.haomeiwen.com/subject/ntxlkqtx.html