vue-router参数传递刷新数据丢失问题

1.使用params方式

另外需要在定义路由时加上参数的userId

this.$router.push({name: bar, params: {userId}})
{path: '/bar/:userId', name: 'bar', component:()=>import ('./bar.vue')}
this.$route.params.userId

2. 使用query方式

this.$router.push({path: '/bar', query:{userId}})
this.$route.query.userId
全部评论

相关推荐

祈求顺利毕业😁:简历很好了,多投吧牛油😂。主要是环境不好,大家也卷
点赞 评论 收藏
转发
头像
04-09 14:29
Java
点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务