Skip to content

表单域配置 FormAreaConfig

默认按钮

  • 显示默认创建、重置按钮defaultCreateBtn defaultRestBtn
ts
interface FormAreaConfig {
  // 表单域默认创建按钮
  defaultCreateBtn?: string | boolean;
  // 表单域默认重置按钮
  defaultRestBtn?: string | boolean;
  ...
}
loading
  • 自定义按钮文本
ts
import type { FormSchema } from "form-cook-render";

const formSchema: FormSchema = {
  formAreaConfig: {
    defaultCreateBtn: "提交", 
    defaultRestBtn: "重置", 
    attrs: {},
  },
};

行内表单

表单中的所有子组件都继承了该表单的 inline 属性。 同样,form-item 也有一个 inline 属性。

ts
interface FormAreaConfig {
  ...
  // 表单域属性配置
  attrs: {
    ...
    //行内表单模式
    inline?: boolean;
  };
  ...
}
loading

校验规则

表单中的所有子组件都继承了该表单的 rules 属性。 同样,form-item 也有一个 rules 属性。

ts
interface FormAreaConfig {
  ...
  // 表单域属性配置
  attrs: {
    ...
    //表单校验规则
    rules?: FormRules;
  };
  ...
}
loading
ts
import type { FormSchema } from "form-cook-render";

const formSchema: FormSchema = {
  ...
  formAreaConfig: {
    ...
    attrs: {
      //校验规则
      rules?: FormRules;
      ...
    },
  },
  ...
};

标签宽度及位置

表单中的所有子组件都继承了该表单的 标签宽度及位置 属性。 同样,form-item 也有一个 标签宽度及位置 属性。

ts
interface FormAreaConfig {
  ...
  // 表单域属性配置
  attrs: {
    ...
    //标签宽度
    labelWidth: string | number;
    //标签位置
    labelPosition: 'left' | 'right' | 'top';
  };
  ...
}
loading

组件大小及禁用

ts
interface FormAreaConfig {
  ...
  attrs: {
    //组件大小
    size?: "large" | "default" | "small";
    //禁用表单
    disabled?: boolean;
    ...
  };
  ...
}
loading

其他属性

属性名说明类型默认值
show-message是否显示校验错误信息booleantrue
inline-message是否以行内形式展示校验信息booleanfalse
status-icon是否在输入框中显示校验结果反馈图标booleanfalse
rules表单验证规则object-
scroll-to-error当校验失败时,滚动到第一个错误表单项boolean-

Released under the MIT License.