Categories
Vue Answers

How to pass a value from Vue.js data to href?

Spread the love

Sometimes, we want to pass a value from Vue.js data to href.

In this article, we’ll look at how to pass a value from Vue.js data to href.

How to pass a value from Vue.js data to href?

To pass a value from Vue.js data to href, we can use template string literals.

For instance, we write

<template>
  <div><a :href="`/job/${r.id}`"</div>
</template>

to set the href prop to /job/${r.id} where r is a reactive property.

Conclusion

To pass a value from Vue.js data to href, we can use template string literals.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *