2

I tried to load some icons and logos into my site using localhost, files are detected but are not loaded and it says "Not allowed to load local resource", I also tried to run the app using "npm install -g http-server" in terminal, but I had another error: "Failed to load resource: the server responded with a status of 404 (Not Found) @build.js:1"

Kraken
  • 31
  • 1
  • 5
  • How are you loading this file? – crimson589 Sep 09 '20 at 06:40
  • using `` – Kraken Sep 09 '20 at 06:42
  • Just to be sure this is a typo, you meant to say you are using `` correct? – Eric Sep 09 '20 at 07:53
  • Well not exactly. I have created some data as objects which include a text, link and a path and that's how i used them: `` *elements is my data, an array including objects, including "src", "href" and "alt" – Kraken Sep 09 '20 at 07:59
  • Ok that's good. If I remember correctly I believe you need to be using the public path if you are going to render images in a loop. Are you using images in the public path or in the assets folder? – Eric Sep 09 '20 at 13:03

1 Answers1

1

There are two common options for loading images.

Through the public folder. e.g. <img src='/image/myImageName.png'>

Note: by specifying the root directory / vue is directed to the public folder

Or through the assets folder. e.g. <img src='@/assets/images/myImageName.png'>

Note: by supplying the @ sign vue is directed to the src directory

Eric
  • 795
  • 5
  • 21
  • I have no problem directing the files, my problem is that my app cannot access the files, I have already mentioned the error message – Kraken Sep 09 '20 at 07:48
  • @Kraken are you using the [vue cli](https://cli.vuejs.org/)? What happens if you use [yarn](https://yarnpkg.com/) e.g. `yarn serve`? – Eric Sep 09 '20 at 07:52
  • uh.. I don't know what is "yarn" but I will search about it – Kraken Sep 09 '20 at 07:55