为什么不按element.src ='…'或setAtribute加载照片

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

这些路径使用html。

路径变化很好,但是照片无法加载

目录和文件:

index.html

img / img-1.png / img-2.png / img-3.png

src / js / app.js

img.src = 'img/img-2.png';
img.setAttribute('src', 'img/img-2.png');
javascript html src
1个回答
0
投票

按F12并检查图像URL。我认为这将是img.setAttribute('src','some path / img / img-2.png');

祝你好运。>>

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