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