Load local images in React.js

后端 未结 10 2096
隐瞒了意图╮
隐瞒了意图╮ 2020-11-30 23:08

I have installed React using create-react-app. It installed fine, but I am trying to load an image in one of my components (Header.js, file path: <

10条回答
  •  孤城傲影
    2020-11-30 23:35

    First, you need to create a folder in src directory then put images you want.

    Create a folder structure like

    src->images->linechart.png
    

    then import these images in JSX file

    import linechart from './../../images/linechart.png'; 
    

    then you need use in images src like below.

    piechart
    

提交回复
热议问题