跳到主要内容

SetValue

为图片表单设置图像。

语法

expression.SetValue(value);

expression - 表示 ApiPictureForm 类的变量。

参数

名称必需/可选数据类型默认值描述
value必需string图像源(URL 或 base64 编码图像)。

返回值

boolean

示例

// The SetValue method of ApiPictureForm is a shorthand for SetImage that fits the unified value interface.

// Create a picture form and assign an image from a URL using SetValue.

let doc = Api.GetDocument();
let pictureForm = Api.CreatePictureForm({"key": "Photo", "tip": "Upload your photo", "required": true, "placeholder": "Photo"});
let paragraph = doc.GetElement(0);
paragraph.AddElement(pictureForm);
pictureForm.SetValue("https://static.onlyoffice.com/assets/docs/samples/img/onlyoffice_logo.png");