在正在测试的代码中,我创建的图像如下:
const image = new Image();
image.addEventListener("load", () => {});
image.addEventListener("error", () => {});
image.src = "hello.png"
当我在浏览器中运行时,我让Webpack将该映像复制到dist目录,它工作正常。不过,我还是觉得这是个错误。
Error: Could not load img: "http://localhost/hello.png"
.
有什么关于如何“服务”这样一个静态图像的笑话指导吗?相对于我的测试文件,图像应该位于哪里?
(注意,我已经添加了
testEnvironmentOptions: { resources: 'usable' }
在笑话中)