在nuxtjs中构建后,无法在开发人员模式下找到模块'./img.jpg'

问题描述 投票:0回答:1

在开发人员模式下工作良好,在生成后,在上传新图像时在错误下获得此图像,然后尝试渲染图像:

错误:无法找到模块'./2019-10-16T21:50:32.958Zhotel-img.jpg'

enter image description here

这里是方法

docImage(index) {
  let imgPath = this.userDocs[index].document.documentPath;
  imgPath = imgPath.substring(imgPath.indexOf("/") + 1);
  return require(`../../uploads/${imgPath}`);
}
vue.js nuxt.js nuxt
1个回答
1
投票

上传新图像后,尝试渲染图像:

这就是原因。当您需要图像时,它们会在构建时由webpack捆绑在一起。因此,在构建时不可用的任何映像将不可用。

© www.soinside.com 2019 - 2024. All rights reserved.