Reputation: 361
I have an vue app with many routes. Whenever I try to reload a page it is always redirecting me to the home page instead of refreshing the current page.
Below is my router setting:
export default new Router({
mode: 'history',
base: process.env.BASE_URL,
routes: [
{
path: '/',
name: 'home',
component: Home,
children: [
{
path: "/dashboard",
name: 'dashboard',
component: DashboardView
},
{
path: "/About",
name:'about',
component: About
},
{
path: "/comments",
name:'comments',
component: Comments
},
]
}
How to refresh the current page instead of redirection to home page.
Upvotes: 5
Views: 5736
Reputation: 33
Well, assuming your process.env.BASE_URL
exists and it is correct, the home
component is your entry point.
From your routes list you placed About
as a child of home
, probably you meant that to be outside.
Anyway, try to make all of them non-children, once you are sure they all work as expected, try the nested children approach again but please note from the Docs:
Note that nested paths that start with / will be treated as a root path. This allows you to leverage the component nesting without having to use a nested URL.
Reference: https://router.vuejs.org/guide/essentials/nested-routes.html
Upvotes: 1