Sometimes, we want to reference static assets within Vue.js and JavaScript.
In this article, we’ll look at how to reference static assets within Vue.js and JavaScript.
How to reference static assets within Vue.js and JavaScript?
To reference static assets within Vue.js and JavaScript, we can use @/
as the alias of the src/
folder.
For instance, we write
<img src="@/assets/images/home.png"/>
to set the src attribute of the img element to @/assets/images/home.png
which is the same as src/assets/images/home.png
in the Vue project folder.
Conclusion
To reference static assets within Vue.js and JavaScript, we can use @/
as the alias of the src/
folder.