the story:
I am on product page #/product/7
and on the same page I have 4 more products that are similar to the one that is being viewed. All these products have links to their pages:
router-link(:to="{ name: 'product', params: { id: product.id }}" v-text='product.title')
.
the problem:
When I click on any of the product links, the url changes but the content remains the same. So, if I am on #/product/7
and click on #/product/8
the url only will change. If I navigate from /product/:id
page and click on a product it takes me to the right page with proper content.
As you can see on screenshot, current product id is 15, but the content is the one from the id 7, as shown in url at the bottom while I was hovering over the Sleek Silk Shirt product in cart. Any ideas how to fix this?
I couldnt really internalise the above answer with 'getProduct', so to be put simply.
I am using a Store and I needed to watch the $route and when it changes I called my store to dispatch the api call.
So basically watch the route and if it changes, re do your api call.
You have to update the data of products variable when you change the route as vue optimises page reloads and does not reload in your case if you are on same route.
You can adapt the approach:
Fetching Before Navigation
described in vue-router docs: