我试图将Instagram嵌入到我的反应应用程序中,但由于某种原因,图像没有被渲染。
这解决了这个问题:
this.setState({
mainImage: data.mainImage,
uuid: data.uuid,
title: data.title,
author: data.author,
tags: data.tags,
premium: data.premium,
preamble: data.preamble,
body: data.body,
publishingTime: data.publishingTime,
},() =>{
const instagramScript = document.createElement("script");
instagramScript.src = "//www.instagram.com/embed.js";
instagramScript.async = true;
document.body.appendChild(instagramScript);
const twitterScript = document.createElement("script");
twitterScript.src = "https://platform.twitter.com/widgets.js";
twitterScript.charset = "utf-8";
twitterScript.async = true;
document.body.appendChild(twitterScript);
});