GetRole
返回当前表单的角色。
语法
expression.GetRole();
expression - 表示 ApiCheckBoxForm 类的变量。
参数
此方法没有任何参数。
返回值
string
示例
此示例展示如何获取表单元素的角色。
const doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
const roles = doc.GetFormRoles();
const rolePr = { "color": "#ffefbf" };
roles.Add("MY_ROLE", rolePr);
const textForm = Api.CreateTextForm({
"tip": "Enter your first name",
"required": true,
"placeholder": "First name",
"comb": true,
"maxCharacters": 10,
"cellWidth": 3,
"multiLine": false,
"autoFit": false
});
paragraph.AddElement(textForm);
textForm.SetRole("MY_ROLE");
const role = textForm.GetRole();
paragraph = Api.CreateParagraph();
paragraph.AddText("Form role: " + role);
doc.Push(paragraph);