Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Append id to router-link in vue.js

I'm running Vue.js and have a for-loop and a trying to generate links with href like /car/xyz:

<router-link to="/car/+ car.id">{{ car.id }}</router-link>

But it fails to render correctly, as I guess I'm appending the car.id wrong to the to value?

like image 913
Alfred Balle Avatar asked Aug 31 '25 01:08

Alfred Balle


1 Answers

Just replace to with :to and format value as a string:

<router-link :to="'/car/' + car.id">{{ car.id }}</router-link>
like image 132
Fab Avatar answered Sep 03 '25 04:09

Fab