Skip to content

Instantly share code, notes, and snippets.

@bang9
Last active March 9, 2022 05:36
Show Gist options
  • Save bang9/8d14feea6e51bb91413e8e06269a4300 to your computer and use it in GitHub Desktop.
Save bang9/8d14feea6e51bb91413e8e06269a4300 to your computer and use it in GitHub Desktop.

절대경로 및 상대경로는 의사적으로만 표기하고, 정확하게 표기하지 않음

  1. 이미지가 public 폴더에 있는 경우
// 이미지 경로: public/og.jpeg
<img src={"/og.jpeg"} style={{ width: 300, height: 300 }} />
  1. 이미지가 src/images 폴더에 있는 경우
// 이미지 경로: src/images/og.jpeg
<img src={require("images/og.jpeg").default} style={{ width: 300, height: 300 }} />

혹은

import bgImage from "images/og.jpeg";
<img src={bgImage} style={{ width: 300, height: 300 }} />
  1. 이미지가 src/images 폴더에 있고, css 에서 사용하려는 경우
/* css 경로: src/some-component/image.css */
#image {
   background: url('../images/og.jpeg') center;
}
<div id={'image'} />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment