Categories
Vue Answers

How to concatenate variable and text with Vue.js img src?

Spread the love

Sometimes, we want to concatenate variable and text with Vue.js img src.

In this article, we’ll look at how to concatenate variable and text with Vue.js img src.

How to concatenate variable and text with Vue.js img src?

To concatenate variable and text with Vue.js img src, we can do the concatenation in the src prop.

For instance, we write

<template>
  <img :src="imgPreUrl + 'img/logo.png'" />
</template>

to set the src prop of the img element to the imgPreUrl + 'img/logo.png', which concatenates imgPreUrl and 'img/logo.png' together.

Conclusion

To concatenate variable and text with Vue.js img src, we can do the concatenation in the src prop.

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 *