简体   繁体   中英

Why do I get an error in react regarding my background-image in css

I have no idea why I'm getting this error in my react project. I fixed the URL path and renamed them properly but for some reasons, I keep getting the same error.

This is my CSS:

  background-image: url("../assets/img/header-bg.jpg");

and the other image is

  background-image: url("../assets/img/map-image.png");

This is the error I get:

在此处输入图像描述

if the image doesn't show then the error is this

Error: Can't resolve '../assets/img/header-bg.jpg' in 'C:\Users\bryan\start-bootstrap\src\assets\css'

the pathway of my images and CSS is:

src > assets > img > header-bg.jpg,map-image.png

在此处输入图像描述

My assets folder also has my CSS folder with my styles which includes bootstrap:

src > assets > css > style.css
 
 

Its probably because the Node.js module is searching for /assets/assets/img/map-image.png (it's searching from CSS), that's why your code isn't working, just remove /assets from the property.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM