为什么我的html和js只有一张image.jpg却渲染了2个图片文件。
我使用带有 CSS 和 JSS 以及 Webpack 的静态 Html。
见下图:
代码位于 Github:https://github.com/kevindRuby/hello-webpack-eg1
首选结果:图像在闪烁文本上方显示一次。
您的 main.js 文件中有
import imageSrc from './image.jpg'; // Adjust the path if necessary
const imgElement = document.createElement('img');
imgElement.src = imageSrc;
imgElement.alt = 'Description of image';
document.body.appendChild(imgElement);