Word.ContentControlState enum

注意

此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。

表示内容控件的状态。

注解

API 集:WordApi BETA (仅预览版)

使用方

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-preview-apis/insert-and-change-content-controls.yaml

// Marks the sample content control with a warning.
await Word.run(async (context) => {
    const sampleControl: Word.ContentControl = context.document.contentControls
        .getByTag("ContentControlStateSample").getFirstOrNullObject();
    await context.sync();

    if (sampleControl.isNullObject) {
        console.warn("Run Set up to create the sample content control.");
        return;
    }

    const state: Word.ContentControlState = Word.ContentControlState.warning;
    sampleControl.setState(state);
    await context.sync();
    console.log(`Set sample content control state to ${state}.`);
});

字段

error = "Error"

错误状态。

warning = "Warning"

警告状态。