OneNote.SectionGroupCollection class
代表分区组的集合。
方法
| get |
获取具有指定名称的分区组的集合。 |
| get |
按其在集合中的 ID 或索引获取分区组。 只读。 |
| get |
按其在集合中的位置获取分区组。 |
| load(options) | 将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 |
| load(property |
将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 |
| load(property |
将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 |
| toJSON() | 覆盖 JavaScript |
| track() | 根据文档中的相应更改来跟踪对象,以便进行自动调整。 此调用是 context.trackedObjects.add (thisObject) 的简写。 如果在调用中 |
| untrack() | 释放与此对象关联的内存(如果先前已跟踪过)。 此调用是 context.trackedObjects.remove (thisObject) 的简写。 拥有许多跟踪对象会降低主机应用程序的速度,因此请在使用完毕后释放所添加的任何对象。 需要在内存释放生效之前调用 |
属性详细信息
context
count
items
方法详细信息
getByName(name)
获取具有指定名称的分区组的集合。
getByName(name: string): OneNote.SectionGroupCollection;
参数
- name
-
string
节组的名称。
返回
注解
示例
await OneNote.run(async (context) => {
// Get the section groups that are direct children of the current notebook.
const sectionGroups = context.application.getActiveNotebook().sectionGroups;
// Queue a command to load the section groups.
// For best performance, request specific properties.
sectionGroups.load("id");
// Get the section groups with the specified name.
const labsSectionGroups = sectionGroups.getByName("Labs");
// Queue a command to load the section groups with the specified properties.
labsSectionGroups.load("id,name");
// Run the queued commands, and return a promise to indicate task completion.
await context.sync();
// Iterate through the collection or access items individually by index.
if (labsSectionGroups.items.length > 0) {
console.log("Section group name: " + labsSectionGroups.items[0].name);
console.log("Section group ID: " + labsSectionGroups.items[0].id);
}
});
getItem(index)
按其在集合中的 ID 或索引获取分区组。 只读。
getItem(index: number | string): OneNote.SectionGroup;
参数
- index
-
number | string
分区组的 ID 或集合中的分区组的索引位置。
返回
注解
getItemAt(index)
按其在集合中的位置获取分区组。
getItemAt(index: number): OneNote.SectionGroup;
参数
- index
-
number
要检索的对象的索引值。 从零开始编制索引。
返回
注解
load(options)
将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()。
load(options?: OneNote.Interfaces.SectionGroupCollectionLoadOptions & OneNote.Interfaces.CollectionLoadOptions): OneNote.SectionGroupCollection;
参数
- options
-
OneNote.Interfaces.SectionGroupCollectionLoadOptions & OneNote.Interfaces.CollectionLoadOptions
为要加载的对象属性提供选项。
返回
load(propertyNames)
将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()。
load(propertyNames?: string | string[]): OneNote.SectionGroupCollection;
参数
- propertyNames
-
string | string[]
指定要加载的属性的逗号分隔的字符串或字符串数组。
返回
示例
await OneNote.run(async (context) => {
// Get the section groups that are direct children of the current notebook.
const sectionGroups = context.application.getActiveNotebook().sectionGroups;
// Queue a command to load the section groups.
// For best performance, request specific properties.
sectionGroups.load("name");
// Run the queued commands, and return a promise to indicate task completion.
await context.sync();
// Iterate through the collection or access items individually by index.
// For example: sectionGroups.items[0]
$.each(sectionGroups.items, function(index, sectionGroup) {
console.log("Section group name: " + sectionGroup.name);
console.log("Section group ID: " + sectionGroup.id);
});
});
load(propertyNamesAndPaths)
将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()。
load(propertyNamesAndPaths?: OfficeExtension.LoadOption): OneNote.SectionGroupCollection;
参数
- propertyNamesAndPaths
- OfficeExtension.LoadOption
propertyNamesAndPaths.select 是指定要加载的属性的逗号分隔字符串,以及 propertyNamesAndPaths.expand 指定要加载的导航属性的逗号分隔字符串。
返回
toJSON()
覆盖 JavaScript toJSON() 方法,以便在将 API 对象传递给 JSON.stringify()时提供更有用的输出。 (JSON.stringify反过来调用 toJSON 传递给它的对象的方法。) 虽然原始 OneNote.SectionGroupCollection 对象是 API 对象,但该 toJSON 方法返回一个纯 JavaScript 对象, (类型为 OneNote.Interfaces.SectionGroupCollectionData) ,其中包含一个“items”数组,其中包含从集合的 items 中加载的任何属性的浅层副本。
toJSON(): OneNote.Interfaces.SectionGroupCollectionData;
返回
track()
根据文档中的相应更改来跟踪对象,以便进行自动调整。 此调用是 context.trackedObjects.add (thisObject) 的简写。 如果在调用中 .sync 使用此对象,并且在“.run”批处理的顺序执行之外使用此对象,并且在设置属性或对对象调用方法时收到“InvalidObjectPath”错误,则需要在首次创建对象时将对象添加到跟踪对象集合。
track(): OneNote.SectionGroupCollection;
返回
untrack()
释放与此对象关联的内存(如果先前已跟踪过)。 此调用是 context.trackedObjects.remove (thisObject) 的简写。 拥有许多跟踪对象会降低主机应用程序的速度,因此请在使用完毕后释放所添加的任何对象。 需要在内存释放生效之前调用 context.sync() 。
untrack(): OneNote.SectionGroupCollection;