Skip to content

字段组

field-group 用于数组对象。它可以声明 templatedefaultItemmin/max、展示方式和操作按钮,也支持数组作用域规则。

基础结构:

ts
{
  id: 'contacts',
  type: 'field-group',
  defaultItem: { role: 'backup', name: '', email: '' },
  template: [
    { id: 'role', type: 'select' },
    { id: 'name', type: 'input' },
    { id: 'email', type: 'input' }
  ]
}

数组项内联动建议使用 scope$self

ts
{
  scope: 'contacts[]',
  watch: ['$self.role'],
  when: '$self.role === "owner"',
  effects: [
    { type: 'required', target: '$self.email', value: true }
  ]
}