user13711020
user13711020

Reputation:

How to include local folder images ( assets ) to vue App

I am trying to add an image , in one of the Vue app , i am using "./assets/logo.png" the url of Vue app is http://localhost:8080/#/

What can be the cause of the error ?

Answers Appreciated

Upvotes: 0

Views: 1055

Answers (2)

Dan Knights
Dan Knights

Reputation: 8368

For this to work you need to require the image source, add an extra . at the start so you go out of the components folder, and include .png on the end of it:

{ ... image: require("../assets/logo.png") }

The require is something to do with webpack not knowing where you're referring to without it.

Upvotes: 1

cam
cam

Reputation: 3616

Change "./assets/logo.png" to require('../assets/logo.png')

This tells Webpack to search for that image at that location and replace the reference with an actual value at render time.

Upvotes: 0

Related Questions