【问题标题】:ReactJS Iframe not loading pageReactJS Iframe 未加载页面
【发布时间】:2020-08-03 22:04:53
【问题描述】:

我正在使用 react 来构建一个网络应用程序。我的组件之一是加载外部网站的 iframe 元素。当我在 localhost 上运行 react-app 时,Iframe 会毫无问题地加载外部站点。当我在 AWS Amplify 上部署应用程序时,Iframe 不加载任何内容,并且在检查浏览器中的元素时,在 Iframe 的属性下,我收到以下消息:

src:
[Exception: TypeError: Illegal invocation at HTMLIFrameElement.invokeGetter (<anonymous>:1:142)]
const body = (
    <div className={classes.modal}>
      <iframe className={classes.iframe} src={"http://www.website.com"}></iframe>
    </div>
  );
<Modal>
        {body}
</Modal>

就像我说的,当我在 localhost 上运行它时一切正常,我只需要弄清楚为什么会发生这种非法调用错误。有谁知道这里发生了什么?我一直在寻找2个小时的东西,没有任何进展。谢谢

【问题讨论】:

  • 也许,您是否使用 console.log() 显示 iframe 上下文?
  • 我不确定你的意思

标签: reactjs typeerror aws-amplify


【解决方案1】:

我发现了问题, 我的 Amplify 应用程序是 https,我要加载的内容是 http,浏览器根本不允许将 http 内容加载到 https 页面中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-03-08
    • 2014-02-09
    • 2015-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多