Office.Tab interface 
表示单个选项卡及其应具有的状态。 有关代码示例,请参阅 更改加载项命令的可用性 和 创建自定义上下文选项卡。
注解
要求集: RibbonAPI 1.1
示例
// Create an Office.Tab object (a contextual tab), set its visibility
// and add it to the ribbon.
async function showDataTab() {
    // Create the Office.Tab object.
    const myContextualTab = { id: "CtxTab1", visible: true };
    const ribbonUpdater = { tabs: [ myContextualTab ] };
    await Office.ribbon.requestUpdate(ribbonUpdater);
}
属性
| controls | 指定选项卡中的一个或多个控件,例如菜单项、按钮等。 | 
| groups | 指定选项卡上的一个或多个控件组。 | 
| id | 清单中指定的选项卡的标识符。 | 
| visible | 指定选项卡在功能区上是否可见。 仅用于上下文选项卡。 | 
属性详细信息
controls
指定选项卡中的一个或多个控件,例如菜单项、按钮等。
controls?: Control[];属性值
注解
当对象Tab是传递给 requestUpdateOffice.Ribbon 方法的 Office.RibbonUpdaterData对象的一部分时,此属性指定要更改其启用状态的控件的 ID。 但是,如果选项卡上有属性 groups ,则忽略此属性, controls 并且必须使用指定组的属性来更改已启用状态。
groups
指定选项卡上的一个或多个控件组。
groups?: Group[];属性值
注解
当对象Tab是传递给 requestUpdateOffice.Ribbon 方法的 Office.RibbonUpdaterData对象的一部分时,controls各种 Office.Group 对象的属性指定哪些控件的启用状态已更改;controls对象的 属性Tab将被忽略。
要求集: RibbonAPI 1.1
id
清单中指定的选项卡的标识符。
id: string;属性值
string
示例
// Office.Tab objects are properties of ribbon updater objects that are passed to the 
// Office.ribbon.requestUpdate method. The following shows how to set the visibility of 
// a custom contextual tab.
async function showDataTab() {
    await Office.ribbon.requestUpdate({
        tabs: [
            {
                id: "CtxTab1",
                visible: true
            }
        ]});
}
// The the following does the same thing in TypeScript.
const showDataTab = async () => {
    const myContextualTab: Office.Tab = { id: "CtxTab1", visible: true };
    const ribbonUpdater: Office.RibbonUpdaterData = { tabs: [ myContextualTab ] };
    await Office.ribbon.requestUpdate(ribbonUpdater);
}
visible
指定选项卡在功能区上是否可见。 仅用于上下文选项卡。
visible?: boolean;属性值
boolean
注解
要求集: RibbonAPI 1.2
示例
// Office.Tab objects are properties of ribbon updater objects that are passed to the 
// Office.ribbon.requestUpdate method. The following shows how to set the visibility of 
// a custom contextual tab.
async function showDataTab() {
    await Office.ribbon.requestUpdate({
        tabs: [
            {
                id: "CtxTab1",
                visible: true
            }
        ]});
}
// The following does the same thing in TypeScript.
const showDataTab = async () => {
    const myContextualTab: Office.Tab = { id: "CtxTab1", visible: true };
    const ribbonUpdater: Office.RibbonUpdaterData = { tabs: [ myContextualTab ] };
    await Office.ribbon.requestUpdate(ribbonUpdater);
}