考虑一下:
this.$root.$router.push({
path: '/dashboard',
params: { errors: 'error' },
query: { test: 'test' }
})
我在我的组件中使用它来重定向到另一个 URL,并且发生了一些错误。问题是当我想访问仪表板组件中的 params
字段时,它是空的。 query
字段运行良好。我正在尝试通过 this.$route.params.errors
访问它。
原文由 Jozef Cipa 发布,翻译遵循 CC BY-SA 4.0 许可协议
您只能使用
params
与named
路径(我认为)。例子:
现在它将在
this.$route.params
中具有正确的值。