Menu Close

How to set static image src in Vue.js template with JavaScript?

Sometimes, we want to set static image src in Vue.js template with JavaScript.

In this article, we’ll look at how to set static image src in Vue.js template with JavaScript.

How to set static image src in Vue.js template with JavaScript?

To set static image src in Vue.js template with JavaScript, we set the path relative to the src folder.

For instance, we write

<template>
  <img src="/static/img/clear.gif" />
</template>

to add an img element with src set to a path relative to the src folder to load the image.

Conclusion

To set static image src in Vue.js template with JavaScript, we set the path relative to the src folder.

Posted in vue