Word.ContentControlState enum
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
表示内容控件的状态。
注解
示例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-preview-apis/insert-and-change-content-controls.yaml
// Sets the state of the first content control.
await Word.run(async (context) => {
const state = ($("#state-to-set").val() as unknown) as Word.ContentControlState;
let firstContentControl = context.document.contentControls.getFirstOrNullObject();
await context.sync();
if (firstContentControl.isNullObject) {
console.warn("There are no content controls in this document.");
return;
}
firstContentControl.setState(state);
firstContentControl.load("id");
await context.sync();
console.log(`Set state of first content control with ID ${firstContentControl.id} to ${state}.`);
});
字段
error = "Error" | 错误状态。 |
warning = "Warning" | 警告状态。 |