【问题标题】:React minified error #31: "Objects are not valid as a React child" in IE 11React 缩小错误 #31:IE 11 中的“对象作为 React 子项无效”
【发布时间】:2019-08-22 14:56:53
【问题描述】:

在 IE 11 上浏览我的应用程序时出现 react 错误。具体问题是 React minified error #31

对象作为 React 子对象无效(找到:带键的对象 {$$typeof, type, key, ref, props, _owner})。

这可能与 babel 在 IE 11 上没有正确转换我们的 indexjs 有关。

【问题讨论】:

  • babel 不会在浏览器上转译代码。它只在您的机器上执行一次,并且在所有浏览器中加载相同的代码。
  • 面临同样的问题,这对你有用吗?

标签: javascript reactjs internet-explorer-11


【解决方案1】:

您可能缺少“babel-polyfill”。 一开始就要求它。 您可能想检查这些链接 https://babeljs.io/docs/usage/polyfill/

https://github.com/storybooks/storybook/issues/213

【讨论】:

    【解决方案2】:

    在你的应用中安装插件 babel-polyfill。

    npm install --save @babel/polyfill      
    

    在应用程序的入口点顶部使用 require 包含您需要的 polyfill。 (app.jsindex.js)

    require("babel-polyfill");
    

    【讨论】:

    • 安装这个包并不能解决问题,使用 require/import 会导致编译错误。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-09-27
    • 2018-11-12
    • 1970-01-01
    • 1970-01-01
    • 2021-08-20
    • 2021-08-05
    • 2022-01-10
    相关资源
    最近更新 更多