F
F
frty2020-11-25 16:00:31
Vue.js
frty, 2020-11-25 16:00:31

How to specify the absolute path to a file from a component?

Hello, tell me why I can't specify the absolute path to the image, which is located in the static(folder in the root of the site) from the component? And if I have components at the 4th nesting level, I will not put ../../../../?

<button @click="openModal">
       <img src="/static/images/icon.svg">
</button>

if I write a relative path , the image sees
<button @click="openModal">
       <img src="../../../static/images/icon.svg">
</button>

Project created with vue cli

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nedosekinstanislav, 2020-11-25
@nedosekinstanislav

Try to enter the symbol ~ or @, for src it starts from the root of the project and then for example '~/public/assets/images/icon.svg'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question