【问题标题】:Unknown element shows up in may create-react-app Application with Typescript未知元素出现在使用 Typescript 的可能 create-react-app 应用程序中
【发布时间】:2021-12-31 11:28:34
【问题描述】:

我用 Typescript 研究 React 应用程序。我的问题是未知的 HTML iframe HTML 元素在开发服务器工作时显示在应用程序公用文件夹的 index.html 的 body 元素中的 id="root" 元素之外。它的 z-index 会阻止鼠标在应用程序上的所有输入。我怎样才能删除这个?你能帮帮我吗?

渲染文件

ReactDOM.render(
  <React.StrictMode>
    <ThemeProvider theme={theme}>
      <App />
    </ThemeProvider>
  </React.StrictMode>,
  document.getElementById('root')
);

index.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>React App</title>
  </head>
  <body>
    <noscript>You need to enable JavaScript to run this app.</noscript>
    <div id="root"></div>
  </body>
</html>

开发服务器工作时 index.html 中的未知元素。

<body>
    <div id="root"></div>

    <iframe style="position: fixed; top: 0px; 
    left: 0px; width: 100%; 
    height: 100%; border: none; 
    z-index: 2147483647;">
    </iframe>
</body>

【问题讨论】:

  • 你使用浏览器扩展吗?
  • 不,我没有任何扩展名。

标签: javascript typescript create-react-app


【解决方案1】:

我在本地开发机器上遇到了同样的问题。我解决了这个问题。但我的解决方案是蛮力解决方案(不是理想或实际的解决方案)。我在全球范围内使用了这个 css。

iframe {
  display: none !important;
}

unknown injected iframe

【讨论】:

猜你喜欢
  • 2018-08-04
  • 2021-03-27
  • 2019-05-10
  • 2019-01-10
  • 1970-01-01
  • 2020-09-30
  • 2019-07-12
  • 2020-04-02
  • 2019-04-07
相关资源
最近更新 更多