[Vuejs]-Vuejs insert image in raw html

3๐Ÿ‘

v-html will render value as HTML without any change in the browser.

So you canโ€™t pass vue or javascript code (:src="@/assets/image.png") to this.

From the documentation:

the contents are inserted as plain HTML - they will not be compiled as Vue templates

๐Ÿ‘คQuoc-Anh Nguyen

0๐Ÿ‘

<img src="@/assets/image.png" alt="image description">

This is correct, if the image is not loading then you have not put it in the correct directory.

@/assets are loaded from src/assets and the compiler optimizes and builds them out to public dir.

It is an alias:

@ = src

๐Ÿ‘คMarc

Leave a comment