OfficeJS Word 插件开发:Firefox 中的 Office.context.document.getFilePropertiesAsync() 总是导致 status = error

问题描述

我希望一些 OfficeJS 人员能够确定这是否是 FF 中 Word 插件 API 的已知问题。 给定代码

 private getFilePropertiesAsync() {
    Office.context.document.getFilePropertiesAsync((asyncResult: AsyncResult<Office.FileProperties>) => {
        if ((Office.AsyncResultStatus.Succeeded !== asyncResult.status)) {
            this.logger.error(asyncResult.error.message);
        } else {
            // do stuff
        }
    });
}

Firefox 中的 asyncResult.status 始终处于“失败”状态。任何 Chromium 浏览器或 IE(或桌面)都可以。

Office.context.document.getFileAsync() 在 FF(以及其他任何地方)中似乎没问题,这让我怀疑 getFilePropertiesAsync() 可能存在错误。我没有在 MS 论坛上找到任何有意义的内容。

碰巧在 FF 84、Win 10 1909 中的任务窗格应用程序中使用 Angular 8。同事看到此加载项的行为相同

解决方法

能否请您在脚本实验室中尝试以下代码片段?我在 FF 中尝试过,效果很好。

function getFilePropertiesAsync() {
  Office.context.document.getFilePropertiesAsync(function (asyncResult) {
    if ((Office.AsyncResultStatus.Succeeded !== asyncResult.status)) {
      this.logger.error(asyncResult.error.message);
    } else {
      console.log(asyncResult.status.toString());
      var fileUrl = asyncResult.value.url;
      if (fileUrl == "") {
        console.log("The file hasn't been saved yet. Save the file and try again");
      }
      else {
        console.log(fileUrl);
      }
    }
  });
}

办公版本:16.0.13911.41002

FF:86.0.1(64 位)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...