office.js - Office 未定义

问题描述 投票:0回答:1

我正在尝试使用 Office.js,但我在控制台中收到以下错误:

“未捕获的引用错误:Office 未定义”

我已经在我的 head 标签中定义了 office.js,如下所示:

<head> 
  <meta charset="UTF-8" /> 
  <script src="appsforoffice.microsoft.com/lib/1/hosted/office.js" type="text/javascript"></script> 
  <meta http-equiv="Content-Security-Policy" content="default-src 'self'; frame-ancestors 'self' https://*.outlook.com;"> 
  <script src="jquery/jquery-1.11.3.js" type="text/javascript"></script> 
  <!-- Office JavaScript API --> 
  <script type="text/javascript" src="appsforoffice.microsoft.com/lib/1/hosted/…> 
</head>

但我还是收到了这个错误。

将此代码显示为错误行;

Office.onReady(function (info) {
  if (info.host === Office.HostType.Outlook) {
    if (info.isReady) {
      initializeOutlookAddIn();
    } else {
      console.error("Office API is not fully loaded for Outlook.");
    }
  } else {
    console.error("Office API is not ready for Outlook.");
  }
});
javascript html outlook office-js office-addins
1个回答
0
投票

Office.onReady(函数 () {

//这里是你的代码

})

在您的 JavaScript 文件中使用此文件,所有与 Office API 相关的内容都将包含在其中

© www.soinside.com 2019 - 2024. All rights reserved.