验证码: 看不清楚,换一张 查询 注册会员,免验证
  • {{ basic.site_slogan }}
  • 打开微信扫一扫,
    您还可以在这里找到我们哟

    关注我们

this.$router.push携带参数跳转页面怎么实现

阅读:982 来源:乙速云 作者:代码code

this.$router.push携带参数跳转页面怎么实现

      前言

      this.$router.push进行页面跳转时。携带参数有params和query两种方式。

      一、params和query使用方式

      query方式:
      this. r o u t e r . p u s h ( p a t h : ′ t e s t Q u e r y ′ , q u e r y : t e s t Q u e r y : ′ t e s t Q u e r y ′ ) , 传 递 的 参 数 会 拼 接 在 跳 转 地 址 的 后 面 。 使 用 t h i s . router.push({path: 'testQuery',query: {testQuery:'testQuery'}}),传递的参数会拼接在跳转地址的后面。使用this. router.push(path:′testQuery′,query:testQuery:′testQuery′),传递的参数会拼接在跳转地址的后面。使用this.route.params.key取值
      params方式:
      this. r o u t e r . p u s h ( n a m e : ′ t e s t P a r a m s ′ , p a r a m s : t e s t P a r a m s : ′ t e s t P a r a m s ′ ) , 传 递 的 参 数 不 会 拼 接 在 跳 转 的 后 面 。 使 用 t h i s . router.push({name: 'testParams',params: {testParams:'testParams'}}),传递的参数不会拼接在跳转的后面。使用this. router.push(name:′testParams′,params:testParams:′testParams′),传递的参数不会拼接在跳转的后面。使用this.route.query.key取值

      二、实现代码

      1.index.js代码

      const router = new Router({
          routes: [
              {
                  path:'/test',
                  component: test,
              },
              {
                  name: 'testParams',
                  path:'/testParams',
                  component: TestParams,
              },
              {
                  path:'/testQuery',
                  component: TestQuery,
              }
          ]
      })

      2.test.vue代码

      
      

      3.testParams代码

      
      
      

      4.testParams代码

      
      
      

      5.效果

      this.$router.push携带参数跳转页面怎么实现

      this.$router.push携带参数跳转页面怎么实现

      this.$router.push携带参数跳转页面怎么实现

    分享到:
    *特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: hlamps#outlook.com (#换成@)。
    相关文章
    {{ v.title }}
    {{ v.description||(cleanHtml(v.content)).substr(0,100)+'···' }}
    你可能感兴趣
    推荐阅读 更多>