Preact-cli: how can i get the img from asset floder

Created on 16 Apr 2018  路  4Comments  路  Source: preactjs/preact-cli


Do you want to request a feature or report a bug?

What is the current behaviour?
the image is in the asset floder , in the router js file , i add the code like this

<img class={style.pic} scr="../../assets/images/img.png" />

but the image don't show , also there is no error, then , I add 'src': source('src'), in the alias ,

<img class={style.pic} scr="src/assets/images/img.png" />

the image still don't show

Most helpful comment

@matthewlynch oh, no, my mistake, thanks for your help

All 4 comments

Hi @dsky1990,

If you're putting images in /src/assets/images then the public path would be: /assets/images e.g:

<img class={style.pic} scr="/assets/images/img.png" />

Hope this helps.

@matthewlynch
image
I try, but still not work
image

HI @dsky1990,

Sorry - I just realised the img tag is missing the src attribute.

Could you try this:

<img class={style.pic} src={imgURL} />

@matthewlynch oh, no, my mistake, thanks for your help

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ajay28kumar picture ajay28kumar  路  3Comments

haggen picture haggen  路  3Comments

thangngoc89 picture thangngoc89  路  3Comments

oren picture oren  路  3Comments

jpoo90 picture jpoo90  路  4Comments