我需要Exchange 2013帐户支持的Outlook Web加载项。因此,在为Outlook Web App添加清单文件后,加载项加载良好。
我正在使用Dialog API弹出窗口来实现登录功能。因此,当客户点击登录按钮时,它会显示Cannot read property 'displayDialogAsync' of undefined
调试时,我知道 Office.context 不包含 ui 属性。
谁能指导我要去哪里错了?或包含交换帐户的Outlook Web App是否支持此Dialog API。
我的加载项在Outlook Desktop,Outlook Web和 也可以移动
if (window.hasOwnProperty('Office')) {
Office.context.ui.displayDialogAsync(
`${window.location.origin}/#/signin/` + Office.context.mailbox.userProfile.emailAddress,
{
height: 60,
width: 20
},
(result) => {
const dialog = result.value;
dialog.addEventHandler(
Office.EventType.DialogMessageReceived,
(e: { type: string, message: string }) => {
if (e.message === 'true') {
this.oAuthService.initImplicitFlow();
}
dialog.close();
});
}
);
}
答案 0 :(得分:0)
需求集是API成员的命名组。 Office加载项使用清单中指定的要求集或使用运行时检查来确定Office主机是否支持加载项所需的API。有关更多信息,请参见Office版本和要求集。在DialogApi
要求集中为Word,Excel或PowerPoint加载项提供了displayDialogAsync方法,在Outlook的邮箱要求集1.4中提供了此方法。
有关{strong> Dialog API 的要求的更多信息,请参见Dialog API requirement sets。
您的回调需要检查result.error.code
和result.error.message
。一旦知道了错误所在,就可以开始故障排除。例如。
var dialog;
Office.context.ui.displayDialogAsync('https://myDomain/myDialog.html',
function (asyncResult) {
if (asyncResult.status === Office.AsyncResultStatus.Failed) {
showNotification(asyncResult.error.code = ": " + asyncResult.error.message);
} else {
dialog = asyncResult.value;
dialog.addEventHandler(Office.EventType.DialogMessageReceived, processMessage);
}
});