1.this.$route.query的使用

(1)、传参数:

this.$router.push({
         path: '/checkout',
         query:{
               productId:id,
          }
}

(2)、获取参数:

this.$route.query.productId

(3)、在url中形式(url中带参数)

http://xxx/#/goodsDetails?productId=150642571432849

(4)、页面之间用路由跳转传参时,刷新跳转后传参的页面,数据还会显示存在(项目中遇到此问题)

2.this.$route.params的使用

(1)、传参数:

// An highlighted block
this.$router.push({
         name: 'checkout',
         params:{
               productId:id,
          }
};

(2)、获取参数:

// An highlighted block
this.$route.params.productId

(3)、在url中形式(url中不带参数)

// An highlighted block
http://172.19.186.224:8080/#/checkout

(4)、页面之间用路由跳转传参时,刷新跳转后传参的页面,数据不存在((url中没带参数))

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐