在将basePath设置为next.config.js后,我常常在path“/public/资产/映像/media/example.svg”中显示svg
basePath: '/exmplpath',
正确的路径是什么?("/exmplpath/public/assets/images/media/example.svg“不起作用)
发布于 2022-07-09 18:37:58
在文件next.config.js
中,需要将其设置为
publicRuntimeConfig:{ basePath: process.env.BASE_PATH basePath '‘}
因此,您可以通过以下方式访问它:
从'next/ config‘导入配置配置
然后使用它作为变量
const {publicRuntimeConfig} = config();
然后你的形象之路
${publicRuntimeConfig}/assets/images/media/example.svg}
如果你知道更多的信息或解释,请告诉我!
https://stackoverflow.com/questions/72923696
复制相似问题