我正在尝试将本地图像放入img src中,但出现这样的错误:
找不到模块'../../ image / image1.jpg'
我已经尝试过
<img src={require(girls.Image)} alt="logo" height="100%" width="100%" />
const Allgirls = response.data.map((girls) =>
<div id='fullUser'>
<div id='User'>
<div id='ImgLogo'>
<img src={require(girls.Image)} alt="logo" height="100%" width="100%" />
</div>
</div>
</div>
)
答案 0 :(得分:1)
尝试这种方式。
//import your image like below
import girl from "./assets/image/girl.png"; //relative path of your image
//use like this
<img src={girl} alt="logo" height="100%" width="100%" />