首页 > 解决方案 > 如何使用 create-react-app 将样式导入 iframe?

问题描述

我正在使用 CRA (create-react-app) 创建一个网站。在这个网站中,我使用 React.createPortal 将组件注入到 iframe 中,如下所示:

ReactDOM.createPortal(
  <SomeComponent />,
  this.iframeRef.current.contentDocument.body
);

但是样式显然没有传递到 iframe 中。像这样:https ://codesandbox.io/s/kk05rl6kpv 。

关于如何将样式表块移动到 iframe 中的任何想法?

标签: reactjsiframecreate-react-app

解决方案


推荐阅读