跳到主要内容

SetValue

设置表单字段的值。

语法

expression.SetValue(value);

expression - 表示 ApiFormBase 类的变量。

参数

名称必需/可选数据类型默认值描述
value必需string | boolean要设置的值。

返回值

boolean

示例

// The SetValue method provides a type-agnostic way to set form values across all form types.

// Set the form value and add the form to a document paragraph.

let doc = Api.GetDocument();
let textForm = Api.CreateTextForm({"key": "Name", "tip": "Enter your name", "required": true, "placeholder": "Your name"});
let paragraph = doc.GetElement(0);
paragraph.AddElement(textForm);
textForm.SetValue("Jane Doe");