Akila Godigamuwa
Akila Godigamuwa

Reputation: 21

How to include dynamic content in URL parameters vue js

I want to add a parameter to a URL inside a href attribute. I'm using Vue js and those parameters should be dynamic. How can I do this?

<a href="localhost/doctors?{{ dynamic content }}"> 

or

<a href="localhost/doctors?${"dynamic content"}>

not working. Vue gives me an error that I should bind it. but I tried it too. Couldn't make it work. what is the correct way? I'm a newbie to Vue js.

Upvotes: 0

Views: 1241

Answers (1)

Lakshya Singh
Lakshya Singh

Reputation: 462

You should use backticks inside the quotes and add data binding on href.

<a :href="`localhost/doctors/${dynamic_content}`">

In the above, the dynamic_content can be a computed, data, props or any other reactive property.

Upvotes: 3

Related Questions