跳到主要内容

Delete

删除表单及其内容。

如果 keepContent 为 true,则不删除内容。

继承自 ApiFormBase.Delete。

语法​

expression.Delete(keepContent);

expression - 表示 ApiTextForm 类的变量。

参数​

名称必需/可选数据类型默认值描述
keepContent必需boolean指定是否删除内容。

返回值​

boolean

示例​

从文档中完全移除文本输入字段。

// How do I permanently take out a text field while keeping its copy in a document?

// Erase a specific text entry field without affecting other fields in a document.

const doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText('Original text form: ');

const textForm = Api.CreateTextForm({
'key': 'Personal information',
'tip': 'Enter your first name',
'placeholder': 'First name',
});
paragraph.AddElement(textForm);

paragraph = Api.CreateParagraph();
paragraph.AddText('Copy of the form: ');
doc.Push(paragraph);

const textFormCopy = textForm.Copy();
paragraph.AddElement(textFormCopy);

textForm.Delete();

paragraph = Api.CreateParagraph();
paragraph.AddText('The original text form has been deleted, but the copy remains.');
doc.Push(paragraph);