vue的传参方式汇总和router使用技巧 vue传参方法一 1,路由配置 { path: '/describe/:id', name: 'Describe', component: Describe } 2,使用方法 // 直接调用$router.push 实现携带参数的跳转 this.$router.push({ // 这个id是一个变量,随便是什么值都可以 path: /describe/${id}`, }) 3,获取方法(在describe页面) $route.params.id 使用以上方法可以拿到上个页面传过来的id值 vue传参方法二 1,路由配置 { path: '/describe', name: 'Describe', component: Describe } (这个地方默认配置就可以了,不用做任何的处理) 2,使用方法 this.$router.push({ name: 'Describe', params: { id: id } }) 父组件中:通过路由属性中的name来确定匹配的路由,通过params来传递参数。 3,获取方法(在describe页面) $route.params.id 也用params获取就可以了; vue传参方法三 1,路由配置 { path: '/describe', name: 'Describe', component: Describe } (默认配置) 2,使用方法 this.$router.push({ path: '/describe', query: { id: id } }) (params换成了query) 3,获取方法(在describe页面) $route.query.id (这个地方用query还获取id,和前面用的params获取的区别在于,用query获取的id值会在url中有显示,可以看到你传过来的值) props传值方法 父组件 (table-data这个地方可以随便取名字,不是特定的值)