Reputation: 1534
I'm trying to reload the page component when user clicks on from the edit page, the router doesn't reload and the old edit values remain.
{
path: "/products/new",
component: ProductPage,
meta: {
breadcrumb: [
{ name: "Home", link: "/home" },
{ name: "Products", link: "/products" },
{ name: "New Product" }
]
}
},
{
path: "/products/:id",
component: ProductPage,
meta: {
breadcrumb: [
{ name: "Home", link: "/home" },
{ name: "Products", link: "/products" },
{ name: "Edit Product" }
]
}
}
is there any way we reload the page component when two pages have same Component?
Upvotes: 2
Views: 2438
Reputation: 107
this.$router.go({path:'/products', params:{id:id}})
doesn't work on Vue version 2 and above. I found a workaround if anyone else is having similar issues. Use
this.$router.push({path:'/products', params:{id:id}}, this.onCompleteReload)
And then have the function onCompleteReload like below:
onCompleteReload () {
if (this.existingData) { // Some condition to make sure we are reloading from same route with different parameter.
this.$router.go(0)
}
}
Upvotes: 0
Reputation: 362700
Use $router.go()
...
this.$router.go({path:'/products', params:{id:id}})
Upvotes: 2