gpt4 book ai didi

reactjs - 无法将 Office UI Fabric React 组件添加到现有项目

转载 作者:行者123 更新时间:2023-12-03 14:30:48 32 4
gpt4 key购买 nike

我尝试添加 Office UI Fabric React ComponentsExisting Project 。我的项目是通过 Visual Studio 2019 创建的新 ASP.NET Core Web 应用程序。该项目是通过 React.js 和 Redux 模板使用 ASP.NET Core 3.0(预览版 7)创建的。启动后,我按照 Fabric React - Add to Existing Project docs 进行操作。 .

  1. 我导航到创建的 Web 项目中的 ClientApp 目录。
  2. 执行npm install office-ui-fabric react --save。这导致发现了 1,000 多个漏洞。
  3. 打开 ./ClientApp/src/components/Home.tsx 文件。
  4. 添加了“import {PrimaryButton} from 'office-ui-fabric-react'”行;
  5. 运行应用

这产生了以下错误:

Failed to compile
Type error: Namespace 'React' has no exported member 'ElementType'. TS2694

15 | * Slottable version of React.ReactType
16 | */
17 | export declare type ISlottableReactType<TProps extends ValidProps, TShorthandPromp extends ValidShorthand> = React.ElementType<TProps> & ISlotCreator<TProps, TShorthandProp>;
|
18 | /**
19 | * Props generated by Foundation.
20 | */

请注意:在我添加 Office UI Fabric React 组件之前,该应用程序运行良好。

最佳答案

请注意Fabric 7 requires a minimum of React 16.8.1 and TypeScript 3.3 。您的项目是否明确依赖于@types/react?如果是这样,它也必须是 16.8+。 React.ElementType 最近被添加到 React 类型中,因此这似乎表明您项目中的 React 类型不满足 Fabric 7 的最低版本要求。

关于reactjs - 无法将 Office UI Fabric React 组件添加到现有项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57328138/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com