我正在尝试在React中添加一个图像。但我的图像加载不了。
这是我为图像创建的div:
<div>
<Image src={devsimone} />
</div>
我的进口:
import { BsFillMoonStarsFill } from "react-icons/bs";
import { AiFillLinkedin, AiFillGithub, AiOutlineMail } from "react-icons/ai";
import Image from "next/image";
import devsimone from "../public/public/portphoto.png";
下面是我的图像在我的目录中的位置:
Image in directory
我尝试过的步骤:
- 删除图像并将其添加回
- 直接从目录中复制粘贴图像路径。
- 在目录中移动图像。
1条答案
按热度按时间vuktfyat1#
由于React知道它的Public目录,因此您可以通过仅定义镜像路径将镜像添加到组件。
此处的“/”表示公用文件夹。