我知道在不使用 TypeScript 的情况下使用 Next.js 图像组件时,需要在 中配置 URL next.config.js,但我不确定为什么这不适用于 TypeScript。
....,未在您的图像下配置
next.config.js查看更多信息:https ://nextjs.org/docs/messages/next-image-unconfigured-host
解决方法是什么?或者是我使用常规img标签的唯一选择?
图像组件:
<Image
src="https://images.unsplash.com/photo-1621794279356-0150106a4b45?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1"
alt="blog title"
width="100"
height="100"
/>
Run Code Online (Sandbox Code Playgroud)
next.config.ts
export const images = {
domains: [
"images.unsplash.com"
],
};
Run Code Online (Sandbox Code Playgroud)