Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VueJS View is not refreshing when I change the router paramId

I have the following router that accepts a param ID

{   
   path: '/Filters/Edit/:id',
   name: 'Manager.FilterEditor',
   component: FilterEditor
},

When I try to navigate from one filter to another using router.push, the view remains the same.

router.push({ name: 'Manager.FilterEditor', params: { id: newfilter.id } });

The URL updates to the new ID, but the models remain the same.

like image 380
Menelaos Vergis Avatar asked Oct 16 '25 02:10

Menelaos Vergis


1 Answers

You have to add a key attribute at the router-view in the master view.

<router-view :key="$route.path" />

The key will help VueJS to notice the change and trigger the model bounding and the view redraw.

like image 159
Menelaos Vergis Avatar answered Oct 18 '25 19:10

Menelaos Vergis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!