简体   繁体   English

Office.js还没有完全加载:Outlook Angular插件

[英]Office.js has not been fully loaded yet :Outlook Angular add-in

I have working on Outlook Add-in using Angular. I am getting an error in Outlook for Windows that a component is not loading after loading index page.我正在使用 Angular 处理 Outlook 加载项。我在 Outlook 中收到错误消息 Windows,加载索引页后组件未加载。 This is not happening with Outlook Web App using Chrome and Firefox.使用 Chrome 的 Outlook Web 应用程序和 Firefox 不会发生这种情况。

Error message is:错误信息是:

SCRIPT5022: Office.js has not been fully loaded yet. Please try again 
later or make sure to add your initialization code on the Office.initialize function.
polyfills.bundle.js (2741,25)

this is my index.ts这是我的 index.ts

import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
import * as $ from 'jquery';

declare let Office:any;

function launch() {
  const platform = platformBrowserDynamic();
  platform.bootstrapModule(AppModule)
    .then((success: any) => {
      console.log('SampleAddin: bootstrap success', success);
    })
    .catch((error: any) => {
      console.log('SampleAddin: bootstrap error', error);
    });
}

Office.initialize = reason => {
   console.log('Office intialize.....');

  $(document).ready(function () {   

    if (environment.production) {
      enableProdMode();
    }

    launch();

   });

}

Answer for my own question: I couldn't loading component in outlook mac and windows. But after adding this to polyfills.ts:回答我自己的问题:我无法在 outlook mac 和 windows 中加载组件。但是在将其添加到 polyfills.ts 之后:

import 'core-js/client/shim';

it's working in IE 11 also and it seems that this didn't break other browsers.它也在 IE 11 中工作,而且似乎这并没有破坏其他浏览器。

As per the docs,根据文档,

you have to initialize a add-in using Office.onReady().您必须使用 Office.onReady() 初始化加载项。

Please refer the docs请参考文档

https://learn.microsoft.com/en-us/office/dev/add-ins/develop/initialize-add-in https://learn.microsoft.com/en-us/office/dev/add-ins/develop/initialize-add-in

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM