How to reference static assets with Vue.js?

Sometimes, we want to reference static assets with Vue.js.

In this article, we’ll look at how to reference static assets with Vue.js.

How to reference static assets with Vue.js?

To reference static assets with Vue.js, we can set the src attribute of the img element to a path that starts with @/.

For instance, we write

<img src="@/assets/images/home.png"/>

to set the src attribute of the img element to an image with the path starting with @/.

@/ is a shorthand for the src directory in the Vue project.

Conclusion

To reference static assets with Vue.js, we can set the src attribute of the img element to a path that starts with @/.