cannot import image with create-react-app

前端 未结 5 1386
悲&欢浪女
悲&欢浪女 2021-02-18 21:43

I\'m using create-react-app, and I am struggling to load images. I am following the instructions as specified here, but I keep seeing the following error:



        
5条回答
  •  闹比i
    闹比i (楼主)
    2021-02-18 22:31

    As @archae0pteryx proposed it is much better to separate pictures from the code, so the project public folder should be used instead of src.

    Here is how it works with css:

    1. copy 'img.bmp' into /public
    2. inside .css file/class: background-image: url('/img.bmp');

提交回复
热议问题