Is fetching data in beforeEnter
and pass props to component is OK?
#1938
-
Greetings, I'm finding good data fetching patterns combine with vue-router. const router = VueRouter.createRouter({
history: VueRouter.createWebHistory(),
routes: [
...,
{
path: "/post",
component: PostTableView,
// route navigation guard
beforeEnter: async (to, from, next) => {
await new Promise((resolve) => {
setTimeout(() => {
resolve({ name: "PostTable"});
},3000)
}).then(({name}) => {
to.meta.name = name;
})
next();
},
props: route => {
return {
name: route.meta.name
}
}
},
...
]
}) Also, I wonder why there is no onBeforeEnter hook in vue-router@v4. (Guess route navigation guard's |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I found those and understood why onBeforeEnter not exists.
|
Beta Was this translation helpful? Give feedback.
-
Writing to |
Beta Was this translation helpful? Give feedback.
Writing to
to.meta
is okay, its a fresh object on each navigation