【发布时间】:2022-01-31 02:00:44
【问题描述】:
我正在尝试在引用外部域的 Next.js 项目中使用 <Image> 组件。我只是在本地工作。
我被指示将images.domains 添加到我的next.config.js 文件中,但这似乎不起作用。
https://nextjs.org/docs/messages/next-image-unconfigured-host
next.config.js
module.exports = {
images: {
domains: ['placehold.it'],
},
webpack: (config) => {
config.module.rules.push({
test: /\.svg$/,
use: ['@svgr/webpack'],
});
return config;
},
};
我的头像:
<Image
width={400}
height={300}
src="http://placehold.it/400x300"
/>
我错过了什么吗?
【问题讨论】:
-
无法重现。您是否尝试过删除 .next 文件夹并重新启动服务器?缓存问题是 Next 经常遇到的麻烦。
标签: next.js nextjs-image