有没有办法使用 next.config.js 为 next js 中的所有本地图像设置前缀?

Lok*_*esh 5 next.js nextjs-image

我已经将我的下一个 js 代码与一些静态图像设置到系统中,用作

<Image
  height={50}
  width={140}
  alt="Alt"
  objectFit="contain"
  src="/images/logo.png"
/>
Run Code Online (Sandbox Code Playgroud)

但现在我必须使用 来部署它basePath: '/product。网址工作正常,但图像未加载,我需要/product/images/logo.png在每个 src 之前使用。

有没有办法在 next.config.js 中进行设置,而我不必为系统中的每个图像更改它?

归档时间:

查看次数:

3781 次

最近记录:

2 年,4 月 前