跳到主要内容

Get

根据名称返回自定义属性的值。

语法

expression.Get(name);

expression - 表示 ApiCustomProperties 类的变量。

参数

名称必需/可选数据类型默认值描述
name必需string自定义属性名称。

返回值

string | number | Date | boolean | null

示例

此示例演示如何根据名称获取自定义属性的值。

const doc = Api.GetDocument();
const customProps = doc.GetCustomProperties();

customProps.Add("ExistingProp", "#123456");

const existingProp = customProps.Get("ExistingProp");
const nonExistentProp = customProps.Get("NonExistentProp");

const paragraph = doc.GetElement(0);
paragraph.AddText("Existing Property Value: " + existingProp);
paragraph.AddText("\nNon-Existent Property Value: " + nonExistentProp);