Office js WordWebJS给出错误未捕获(承诺中)RichApi.error
Office js API在调用document.properties.customProperties.getItemOrNullObject方法时出现错误“Uncaught(in promise)RichApi.error”。这在24小时前一直运作良好,所以文件中有东西坏了 错误的全文如下 未捕获(承诺中)RichApi。错误:无法读取null的属性“Y” 在新的c() 在b.e.processRequestExecutorResponseMessage()上Office js WordWebJS给出错误未捕获(承诺中)RichApi.error,office-js,Office Js,Office js API在调用document.properties.customProperties.getItemOrNullObject方法时出现错误“Uncaught(in promise)RichApi.error”。这在24小时前一直运作良好,所以文件中有东西坏了 错误的全文如下 未捕获(承诺中)RichApi。错误:无法读取null的属性“Y” 在新的c() 在b.e.processRequestExecutorResponseMessage()上 在中,我无法再现错误的“未捕获
在中,我无法再现错误的“未捕获(承诺)”部分,但我确实得到了一个RichApi.error,它告诉我加载由
getItemOrNullObject
返回的对象的type
属性,即使我没有读取该属性。如果在同步之前加载对象的type
属性,请查看您的症状是否会改变。我不确定如何以及在何处加载getItemOrNullObject返回的对象的type属性。这是我的函数代码,用于读取属性Word.run(函数(上下文){var myProperty=context.document.properties.customProperties.getItemOrNullObject(“X”);context.load(myProperty);return context.sync()。然后(函数(){if(myProperty.isNullObject){//Null property}else{//nota null property}}}).catch(函数(e){console.log(e.message);})请将您的代码放在原始问题的代码块中以便可读。您的行context.load(myProperty);
相当于myProperty.load()
。这是一个空的加载
,这意味着您正在加载所有标量属性,包括类型
。当我加载类型
时,无论是显式加载还是空加载,我都无法再现您的错误。您能否在原始帖子中提供错误的全文(以及您的代码)?现在,我也无法重现错误。此问题再次出现,并且似乎间歇性出现,没有确定的模式。
Word.run(function (context) {
var myProperty =
context.document.properties.customProperties.getItemOrNullObject("X");
context.load(myProperty);
return context.sync() .then(function () {
if (myProperty.isNullObject) { //Null property }
else { //Not a null property } }) })
.catch(function (e) { console.log(e.message);
})