无法加载本地 office.js
Cannot load local office.js
按照的建议,我想稍微修改一下office.js
。
所以我把https://appsforoffice.microsoft.com/lib/1/hosted/office.js
的内容复制到本地,这样https://localhost:3000/static/office.js
就可以很好的显示内容了
然后,我制作一个非常简单的文件test.html
:
<html>
<head>
<!--<script src="https://appsforoffice.microsoft.com/lib/1/hosted/office.js"></script>-->
<script type="text/javascript" src="https://localhost:3000/static/office.js"></script>
</head>
<body>
haha
</body>
</html>
在浏览器中使用远程 office.js
加载 https://localhost:3000/static/test.html
显示 Warning: Office.js is loaded outside of Office client
o15apptofilemappingtable.js:11
,并在 Office 加载项中加载效果很好。
但是,在浏览器中使用本地 office.js
加载 https://localhost:3000/static/test.html
显示 Uncaught SyntaxError: Unexpected token <
o15apptofilemappingtable.js:1
,而在 Office 加载项中加载它会出现错误 Add-in Error Something went wrong and we couldn't start this add-in. Please try again later or contact your system administrator
。
所以有人知道这里出了什么问题吗?是否可以制作我们自己的本地版本 office.js
?
请参阅我在链接问题中的回答。本质上,不,你不应该制作你自己的 "office.js" 的本地副本。但是,如果您确实想要一个本地副本——我们已经在 NuGet 和最近在 NPM (https://www.npmjs.com/package/@microsoft/office-js) 上提供了它——您还需要该目录中的所有相关文件,而不仅仅是 Office.js本身。
有关构成 Office.js 的文件和文件夹的列表,请参阅 https://unpkg.com/@microsoft/office-js@1.1.1/dist/。并非所有(事实上,不是大部分)都在任何给定会话中使用,但您确实需要整套文件,因为不同的文件在不同的情况下加载。
按照office.js
。
所以我把https://appsforoffice.microsoft.com/lib/1/hosted/office.js
的内容复制到本地,这样https://localhost:3000/static/office.js
就可以很好的显示内容了
然后,我制作一个非常简单的文件test.html
:
<html>
<head>
<!--<script src="https://appsforoffice.microsoft.com/lib/1/hosted/office.js"></script>-->
<script type="text/javascript" src="https://localhost:3000/static/office.js"></script>
</head>
<body>
haha
</body>
</html>
在浏览器中使用远程 office.js
加载 https://localhost:3000/static/test.html
显示 Warning: Office.js is loaded outside of Office client
o15apptofilemappingtable.js:11
,并在 Office 加载项中加载效果很好。
但是,在浏览器中使用本地 office.js
加载 https://localhost:3000/static/test.html
显示 Uncaught SyntaxError: Unexpected token <
o15apptofilemappingtable.js:1
,而在 Office 加载项中加载它会出现错误 Add-in Error Something went wrong and we couldn't start this add-in. Please try again later or contact your system administrator
。
所以有人知道这里出了什么问题吗?是否可以制作我们自己的本地版本 office.js
?
请参阅我在链接问题中的回答。本质上,不,你不应该制作你自己的 "office.js" 的本地副本。但是,如果您确实想要一个本地副本——我们已经在 NuGet 和最近在 NPM (https://www.npmjs.com/package/@microsoft/office-js) 上提供了它——您还需要该目录中的所有相关文件,而不仅仅是 Office.js本身。
有关构成 Office.js 的文件和文件夹的列表,请参阅 https://unpkg.com/@microsoft/office-js@1.1.1/dist/。并非所有(事实上,不是大部分)都在任何给定会话中使用,但您确实需要整套文件,因为不同的文件在不同的情况下加载。