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
全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务