【问题标题】:Angular 6 and Sharepoint SPFXAngular 6 和 Sharepoint SPFX
【发布时间】:2019-01-09 00:23:37
【问题描述】:

只是想知道是否有人有任何示例或指向在 Sharepoint SPFX 上运行 Angular 6 应用程序的说明的链接。

我在 Angular 5 中遵循了这个示例,但是一旦我升级了 Angular 依赖项,它将无法工作

https://www.youtube.com/watch?v=_OgEqWtouuU

当我尝试添加 Web 部件时,我在 SPFX 工作台上遇到的错误是

    [SPLoaderError.loadComponentError]:
***Failed to load component "a884f6f5-e74c-4932-972f-0e1431147413" (AppWebPart).
Original error: ***loadComponent() returned an empty object for component "a884f6f5-e74c-4932-972f-0e1431147413" (AppWebPart).

***INNERERROR:
***loadComponent() returned an empty object for component "a884f6f5-e74c-4932-972f-0e1431147413" (AppWebPart).
***CALLSTACK:
Error
    at SPLoaderError.SPError [as constructor] (https://localhost:4321/node_modules/@microsoft/sp-loader/dist/sp-loader-assembly_en-us.js:10183:24)
    at new SPLoaderError (https://localhost:4321/node_modules/@microsoft/sp-loader/dist/sp-loader-assembly_en-us.js:4211:28)
    at Function.ErrorBuilder.buildErrorWithVerboseLog (https://localhost:4321/node_modules/@microsoft/sp-loader/dist/sp-loader-assembly_en-us.js:3821:21)
    at Function.ErrorBuilder.buildLoadComponentError (https://localhost:4321/node_modules/@microsoft/sp-loader/dist/sp-loader-assembly_en-us.js:3743:21)
    at https://localhost:4321/node_modules/@microsoft/sp-loader/dist/sp-loader-assembly_en-us.js:7952:38

代码可在此链接https://drive.google.com/file/d/1iF1Low1VYlK0RFYXf1KILZfcEuLnMIjx/view?usp=sharing

非常感谢任何帮助。

谢谢 达米安

【问题讨论】:

    标签: angular gulp angular6 spfx sharepointframework


    【解决方案1】:

    我设法让它独立运行 Angular 解决方案并从 Angular 自定义元素启动应用程序,如下所示:

    export class AppModule {
     constructor(private injector: Injector) {   }
    
     ngDoBootstrap(appRef: ApplicationRef) {
         if (!customElements.get('app-root')) {
         const helloElement = createCustomElement(AppComponent, { injector: this.injector });
         customElements.define('app-root', helloElement);
       }
     }
    

    来源:http://www.andrewconnell.com/blog/howto-angular-elements-in-sharepoint-framework-projects-two-projects?utm_source=accom&utm_medium=blog&utm_campaign=Using%20Angular%20Elements%20in%20SharePoint%20Framework%20Projects%20Series

    还有我的 git 仓库:https://github.com/clementlepere/SPFX-AngularElements

    它仍然是 WIP,在运行构建脚本时我遇到了一些编码问题(在运行 gulp serve 之前使用像 notepad++ 这样的编码转换器修复)

    【讨论】:

      猜你喜欢
      • 2018-09-14
      • 2019-09-22
      • 1970-01-01
      • 2021-04-06
      • 2021-09-30
      • 2023-03-06
      • 2020-05-22
      • 2020-06-25
      • 2019-04-02
      相关资源
      最近更新 更多