ekjcfn3902039
ekjcfn3902039

Reputation: 1839

Vue router dynamic params

I cannot figure out the correct syntax for passing dynamic param data. I have tried a couple of variations, but I would assume I could inject someValue via:

<router-link :to="{ name: 'Foo', params:{ bar: ${someValue} } }">

However, I keep getting compiler errors.

Upvotes: 1

Views: 152

Answers (1)

Boussadjra Brahim
Boussadjra Brahim

Reputation: 1

You could pass any dynamic property via router-link params like :

 <router-link :to="{ name: 'Foo', params:{ bar:someValue} }">

someValue sould be a data object item or computed property, and if you want to pass a value returned with a method you could do it like :

<router-link :to="{ name: 'Foo', params:{ bar:someMethod()} }">

Upvotes: 2

Related Questions