代码之家  ›  专栏  ›  技术社区  ›  Damien

Angular 6和Sharepoint SPFX

  •  0
  • Damien  · 技术社区  · 6 年前

    只是想知道是否有人有任何样本或链接到在sharepointspfx上运行angular6应用程序的说明。

    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

    非常感谢任何帮助。

    谢谢你

    1 回复  |  直到 6 年前
        1
  •  0
  •   clepere    5 年前

    我设法让它独立运行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

    它仍然是非常在制品的,我在运行构建脚本时遇到了一些编码问题(在运行gulp-serve之前使用了一个编码转换器,比如notepad++)