javascript - react image wont load - Stack Overflow

<imgsrc={siswa.url}alt={`Profile of ${siswa.nama1}`}className={styles.image}onError={(e) => {conso

      <img
        src={siswa.url}
        alt={`Profile of ${siswa.nama1}`}
        className={styles.image}
        onError={(e) => {
          console.error("Image failed to load:", e.target.src);
          e.target.style.display = "none"; // Hide the broken image
        }}
      />

on the console chrome it say failed to load and also when I browse the link it say Cannot GET /images/e45c416f7e189371d42a196f2bacf989.jpg

      <img
        src={siswa.url}
        alt={`Profile of ${siswa.nama1}`}
        className={styles.image}
        onError={(e) => {
          console.error("Image failed to load:", e.target.src);
          e.target.style.display = "none"; // Hide the broken image
        }}
      />

on the console chrome it say failed to load and also when I browse the link it say Cannot GET /images/e45c416f7e189371d42a196f2bacf989.jpg

Share Improve this question edited Mar 2 at 9:25 qowi asked Mar 2 at 9:24 qowiqowi 12 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0
/images/e45c416f7e189371d42a196f2bacf989.jpg 

This looks like a relative path. You can try to use an absolute image path(full root path of the image on your machine) to see if the issue is caused by your image path; If the problem still exists, check if your backend server is setup serve static files

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745126466a4612719.html

相关推荐

  • javascript - react image wont load - Stack Overflow

    <imgsrc={siswa.url}alt={`Profile of ${siswa.nama1}`}className={styles.image}onError={(e) => {conso

    10小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信