正如Next Js文档中所描述的那样,我添加了一个Next.config.Js文件来告诉Next Js我想将小猫加载到我的应用程序中。
这是资源:
https://placekitten.com/640/360
next.config.js如下所示:
module.exports = {
images: {
domains: ["placekitten.com"],
},
};
在我的组件中,它看起来是这样的:
import Link from "next/link";
import Image from "next/image";
export default function SidebarItem({
categories = [
"Get the Look",
"Clothing",
"Shoes",
"Sports",
],
}) {
return (
<section className='flex'>
<Image
alt='Picture of the author'
width={300}
height={300}
src='/640/360'
/>
</section>
);
}
我收到以下错误:图片:1 GEThttp://localhost:3000/_next/image?url=%2F640%2F360&w=640&q=75 400(错误请求(
我做错了什么?
您忘记设置图像的完整路径:
<Image
alt='Picture of the author'
width={300}
height={300}
src='https://placekitten.com/640/360'
/>