***更新:好的,我已经玩过了。如果您只是绕过document.write并直接使用危险的lysetinnerhtml添加iframe,它就可以工作。我在下面添加了一个工作代码沙盒和一个代码示例。
希望有帮助!
https://codesandbox.io/s/z6k1w94z8m
import React from "react";
import { render } from "react-dom";
const App = () => {
return <div dangerouslySetInnerHTML={{__html: `
<iframe src="https://www.cricruns.com/widgetbase/wid_300_200_1"; width=250&colorscheme=light&show_faces=true&stream=false&header=true&height=320 " scrolling="yes" frameborder="0" style="border:none; overflow:hidden; width:310px; height:250px;" allowTransparency="true"></iframe>
`}} />;
};
render(<App />, document.getElementById("root"));