網站搜尋

reactjs - MicrosoftAjax.js 未能在 Office 應用程式中成功加載


我之前使用的是 office-js 的 CDN 發行版本,但不得不改為本地版本。更改後,Office.initialize 似乎沒有被執行,這意味著附加元件無法正常運作。在控制台上,我看到以下錯誤:

SCRIPT5022: MicrosoftAjax.js is not loaded successfully.
office.js (18,26767)

我能找到的唯一關於 MicrosoftAjax.js 的參考都是與 ASP.NET 相關的,但我的專案是 Typescript/React。以下是在 HTML 中載入 office.js 的方式:

<!doctype html>
<html lang="en" data-framework="typescript">

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>wincross-formatter</title>
</head>

<body class="ms-font-m">
  <script src="/assets/office.js"></script>
  <div id="container"></div>
</body>

</html>

我該如何修復這個錯誤?

編輯:

根據此頁面,我在 office-js 腳本上方添加了以下一行:

<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.min.js"></script>

將它加在 office-js 腳本之後給了我這個錯誤,而不是之前的那個,而且 Office.initialize 仍然沒有被調用:

SCRIPT5022: Neither the locale, en-us, provided by the host app nor the fallback locale en-us are supported.

最終編輯:那完全是我的錯。我沒有遞歸地複製 office-js/dist 的內容。