未加载的 InnerHTML,javascript,html,reactjs"/>

首页 > 解决方案 > 未加载的 InnerHTML

问题描述

我直接从 API 获取 HTML 数据,确切地说是ComicVine。并且在加载一个字符的描述时,前 2 个图像正在加载一个正常的 src 值,但是从第三个图像开始,src 值开始是 'data/image/gif...' 并且这些没有加载,只是图像应该在的空白方块。

这是带有描述 html 的 div:

<div dangerouslySetInnerHTML={{ __html: character.description }} />

编辑

这是前 2 张图片在描述中加载的方式:

<figure data-align="right" data-size="medium" data-img-src="https://static.comicvine.com/uploads/original/0/229/79548-18133-wolverine.jpg" data-ref-id="1300-79548" data-ratio="1.288" data-width="250" data-embed-type="image" style="width: 250px">
 <a class="fluid-height" style="padding-bottom:128.8%" href="https://static.comicvine.com/uploads/original/0/229/79548-18133-wolverine.jpg" data-ref-id="1300-79548">
  <img alt="No Caption Provided" src="https://comicvine.gamespot.com/a/uploads/original/0/229/79548-18133-wolverine.jpg" srcset="https://comicvine.gamespot.com/a/uploads/original/0/229/79548-18133-wolverine.jpg 250w" sizes="(max-width: 250px) 100vw, 250px" data-width="250">
 </a>
</figure>

这是未加载的图像类型:

<figure data-align="right" data-size="small" data-ref-id="1300-1863610" data-img-src="https://static.comicvine.com/uploads/original/4/49076/1863610-logan_wwi.jpg" data-ratio="0.5225" data-width="400" data-embed-type="image" style="width: 400px">
 <a class="fluid-height" style="padding-bottom:52.3%" href="https://static.comicvine.com/uploads/original/4/49076/1863610-logan_wwi.jpg" data-ref-id="1300-1863610">
  <img alt="Logan in the Great War" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" sizes="(max-width: 320px) 100vw, 320px" data-width="320" class="js-lazy-load-image" data-src="https://comicvine.gamespot.com/a/uploads/scale_small/4/49076/1863610-logan_wwi.jpg" data-srcset="https://comicvine.gamespot.com/a/uploads/original/4/49076/1863610-logan_wwi.jpg 400w, https://comicvine.gamespot.com/a/uploads/scale_small/4/49076/1863610-logan_wwi.jpg 320w">
   <noscript><img alt="Logan in the Great War" src="https://comicvine.gamespot.com/a/uploads/scale_small/4/49076/1863610-logan_wwi.jpg" srcset="https://comicvine.gamespot.com/a/uploads/original/4/49076/1863610-logan_wwi.jpg 400w, https://comicvine.gamespot.com/a/uploads/scale_small/4/49076/1863610-logan_wwi.jpg 320w" sizes="(max-width: 320px) 100vw, 320px" data-width="320">
  </noscript>
 </a>
 <figcaption>Logan in the Great War</figcaption>
</figure>

而且由于我是从从第 3 方 API 中提取的 json 中获取的,所以我不能那么容易地编辑它的内容(我猜)。

标签: javascripthtmlreactjs

解决方案


推荐阅读