Office.OnReadyOptions interface
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
提供与事件相关的 onReady 选项。
注解
示例
// Enable rejection behavior for the onReady promise.
Office.onReadyOptions?.setRejectionEnabled();
// Now the onReady promise can be rejected if failures are encountered during its setup.
Office.onReady((info) => {
console.log(`Host: ${info.host}, Platform: ${info.platform}`);
}).catch((error) => {
console.error("Office.js initialization failed:", error);
});
属性
| set |
启用允许 |
属性详细信息
setRejectionEnabled
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
启用允许 onReady 在遇到失败时拒绝承诺的行为。 如果未通过,则 onReady 承诺不会拒绝。
setRejectionEnabled?: () => void;
属性值
() => void
示例
// Enable rejection behavior for the onReady promise.
Office.onReadyOptions?.setRejectionEnabled();
// Now the onReady promise can be rejected if failures are encountered during its setup.
Office.onReady((info) => {
console.log(`Host: ${info.host}, Platform: ${info.platform}`);
}).catch((error) => {
console.error("Office.js initialization failed:", error);
});