跳到主要内容

GetOutlineLvl

返回指定属性的大纲级别。

语法

expression.GetOutlineLvl();

expression - 表示 ApiParaPr 类的变量。

参数

此方法没有任何参数。

返回值

Number | undefined

示例

读取文档中不同层次位置段落分配的大纲级别。

// How do I get the outline level of a paragraph in a document?

// Verify the heading structure by checking outline levels across multiple paragraphs in a document.

const doc = Api.GetDocument();
const firstParagraph = doc.GetElement(0);
firstParagraph.AddText('To see outline levels, open "Headings" on the "View" tab.');

const levels = [1, 5, 8];
for (let i = 0; i < levels.length; i++) {
const paragraph = Api.CreateParagraph();
const paraPr = paragraph.GetParaPr();
paraPr.SetOutlineLvl(levels[i]);
paragraph.AddText('Outline level: ' + paraPr.GetOutlineLvl());
doc.Push(paragraph);
}