您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

React无法在Edge中解构restProps

React无法在Edge中解构restProps

经过一段时间的搜索,我找到了解决该问题的方法

在过去的某个时候,React决定从其react-app预设中删除一些babel预设。我将旧项目中的“ babel-preset-react- app”(node_modules中的文件夹)与新创建的react应用(使用create-react-app v3.4创建)的babel- presets进行了比较。通过比较两个应用程序的babel-preset-react- app中的package.json,我发现在较新的版本中,安装的babel插件要少得多。

安装@ babel / plugin-proposal-object-rest-spread(也许还可以确定@ babel / plugin-transform-spread):

npm install @babel/plugin-proposal-object-rest-spread @babel/plugin-transform-spread

完成后,只需将它们作为插件添加到您的react应用程序的package.json中,即可从react导入的预设下面:

"babel": {
    "presets": [ // This line should already be there if you created your project with CRA
      "react-app"
    ],
    "plugins": [
      "@babel/plugin-transform-spread",
      "@babel/plugin-proposal-object-rest-spread"
    ]
  }

希望对您有所帮助!

其他 2022/1/1 18:14:27 有413人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶