[英]How to use NextJS Image Component to display images receiving through props?
Simply I wanna display images that I'm receiving through props
只是我想显示我通过
props
收到的图像
import Image from "next/image";
import classes from "./book-item.module.css";
export default function FoodItems(props) {
return (
<li className={classes.product__item}>
<Image
src={props.imageUrl}
alt={props.title}
className={classes.image}
width={100}
height={100}
/>
<h3>{props.title}</h3>
<p>{props.price}</p>
</li>
);
}
I'm getting this error from the above code:-我从上面的代码中得到这个错误:-
Your error clearly states what you are missing ie you need to add allowed domains for images to load from in next.config.js
file.您的错误清楚地说明了您缺少的内容,即您需要添加允许的域以便在
next.config.js
文件中加载图像。
next.config.js
filenext.config.js
文件images: { domains: ["itbook.store"], },
add all the domains from where you load images in this array images: { domains: ["itbook.store"], },
将你加载图像的所有域添加到这个数组中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.