【问题标题】:Getting issue while implementing FluentUI using SPFx in SharePoint online在 SharePoint Online 中使用 SPFx 实现 FluentUI 时出现问题
【发布时间】:2021-10-23 16:27:33
【问题描述】:

我正在关注this blog 在 SPFX 部分实现 fluentUI,但在执行“Gulp Build”时出现以下错误:

Error - [tsc] node_modules/@fluentui/react/lib/components/GroupedList/GroupedListSection.d.ts(9,38): error TS1005: ';' expected.      
[05:38:38] Error - [tsc] node_modules/@fluentui/react/lib/components/GroupedList/GroupedListSection.d.ts(10,13): error TS1005: '=' expected.     
[05:38:38] Error - [tsc] node_modules/@fluentui/react/lib/components/GroupedList/GroupedListSection.d.ts(10,33): error TS1005: ';' expected.
[05:38:38] Error - [tsc] node_modules/@fluentui/react/lib/components/GroupedList/GroupedListSection.d.ts(11,13): error TS1005: '=' expected.
[05:38:38] Error - [tsc] node_modules/@fluentui/react/lib/components/GroupedList/GroupedListSection.d.ts(11,33): error TS1005: ';' expected.     
[05:38:38] Error - [tsc] node_modules/@fluentui/react/lib/components/GroupedList/GroupedListSection.d.ts(12,13): error TS1005: '=' expected.
[05:38:38] Error - [tsc] node_modules/@fluentui/react/lib/components/GroupedList/GroupedListSection.d.ts(12,32): error TS1005: ';' expected.     
[05:38:38] Error - [tsc] node_modules/@fluentui/react/lib/components/GroupedList/GroupFooter.d.ts(2,13): error TS1005: '=' expected.
[05:38:38] Error - [tsc] node_modules/@fluentui/react/lib/components/GroupedList/GroupFooter.d.ts(2,40): error TS1005: ';' expected.
[05:38:38] Error - [tsc] node_modules/@fluentui/react/lib/components/GroupedList/GroupFooter.d.ts(4,1): error TS1128: Declaration or statement expected.
[05:38:38] Error - [tsc] node_modules/@fluentui/react/lib/components/GroupedList/GroupFooter.d.ts(4,13): error TS1005: ';' expected
................
.......
.......

【问题讨论】:

    标签: sharepoint-online spfx fluentui-react


    【解决方案1】:

    您可以尝试以下方法来解决此问题:

    运行:

    npm i @microsoft/rush-stack-compiler-3.2 typescript@3.2 -D -E
    

    更新 tsconfig.json 文件后:

    "extends": "./node_modules/@microsoft/rush-stack-compiler-3.**2**/includes/tsconfig-web.json"
    

    如果这无助于尝试旧版本:

    npm install @fluentui/react@7.113.0 --save
    

    【讨论】:

    • 试过但没有成功
    • 我有一个可行的解决方案,我已经实施了几天前创建的@fluentui/react。我刚刚从那里复制了 node_modules\@fluentui 文件夹并替换为新的解决方案,现在我的新解决方案也可以工作了。
    【解决方案2】:

    刚刚遇到同样的问题。事实证明,最新版本的 Fluent UI 使用 TypeScript 3.8 语法,因此您需要更新 SPFx 项目使用的版本。详细说明在这里:https://www.voitanos.io/blog/use-different-typescript-versions-in-sharepoint-framework-projects/。我实际上已将我的更新为 @microsoft/rush-stack-compiler-3.9 并且现在工作正常。

    【讨论】:

    • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
    猜你喜欢
    • 2021-12-24
    • 2021-06-10
    • 1970-01-01
    • 2020-03-11
    • 2019-02-06
    • 1970-01-01
    • 2011-11-11
    • 2020-10-19
    • 1970-01-01
    相关资源
    最近更新 更多