在 Vue3 中,有没有一种方法可以将属性传递给路由,而无需在 url 中显示值?
我这样定义路线:
{
path: '/someRoute',
name: 'someRoute',
component: () => import('@/app/pages/SomeRoute.vue'),
props: (route) => {
...route.params
}, // <-- I've seen this method in Vue2 but in Vue3 the route.params is just empty here
}
我这样称呼这条路线:
Some link
当我将路径更改为 path: '/someRoute/:message', 时,消息传递得很好,但我只想传递消息而不将其显示在网址中。
我见过几个使用此方法的 Vue2 示例(例如 https://stackoverflow.com/a/50507329/1572330),但显然它们不再在 Vue3 中工作。
还有 Vue3 文档中的所有示例 (https://github.com/vuejs/vue-router/blob/dev/examples/route-props/app.js / https://v3.router.vuejs。 org/guide/essentials/passing-props.html)通过 url 本身传递它们的值,所以我不确定它是否还可能。
对此的任何想法都会有所帮助。
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号