M
M
MikUrrey2021-06-07 00:42:58
Vue.js
MikUrrey, 2021-06-07 00:42:58

Vue2 + img src: how to properly grab an image?

Greetings!
There is an image that needs to be displayed in the component:

<img class="map" v-if="form.address" src="screens/mages/map.png">

The problem is that it is not possible to force the image to be picked up from the same source at the same time in dev and in prod mode.
If the specified path is inside the public folder, then after assembly in prod, links to it are formed incorrectly, immediately from the domain, while the application lies separately in the folder.
If the path is inside src/assets, then in dev mode the server "does not see" the file for some reason.
@/assets/screens/mages/map.png doesn't work either, doesn't convert to the correct path.
How to be?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Kulakov, 2021-06-07
@MikUrrey

I would go here: https://cli.vuejs.org/guide/html-and-static-assets... and choose one of the options depending on your needs.
One is to put the file directly in the public folder, let's say public/screens/mages/map.png, then the src="/screens/mages/map.png"file should be available along the path.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question