Skip to content

LumalSchemaForm

Schema 驱动表单,支持 create / edit / view 模式与字典联动。

ts
import { LumalSchemaForm } from '@lumal/core/components'
import type { SchemaFormItem, SchemaFormModel } from '@lumal/core/components'

示例

vue
<script setup lang="ts">
import type { SchemaFormItem, SchemaFormModel } from '@lumal/core/components'
import { LumalSchemaForm } from '@lumal/core/components'
import { shallowRef } from 'vue'

const model = shallowRef<SchemaFormModel<{ name: string, status: string }>>({})
const schemas: SchemaFormItem[] = [
  {
    field: 'name',
    label: '名称',
    component: 'input',
    rules: [{ required: true, message: '请输入名称' }],
  },
  { field: 'status', label: '状态', dictionary: 'status' },
]
</script>

<template>
  <LumalSchemaForm
    v-model="model"
    :columns="2"
    label-width="92px"
    :schemas="schemas"
    show-actions
  />
</template>

内置控件

inputtextareaselectnumberswitchdatedatetimedaterangeradiocheckboxtree-selectuploadhidden

字段配置要点

字段说明
field / label / component基础
dictionary字典 options
rules校验
hidden / disabled / readonly布尔或函数
authority / readonlyAuthority权限
formatterview 模式展示
componentProps透传 Element Plus
description / help控件下方说明

插槽

  • field-${field}:整字段接管
  • prefix-${field} / suffix-${field}

模式

  • create / edit:可编辑
  • view:文本语义展示,而非禁用输入框堆叠

更多:Core API · Schema Form

基于 MIT 许可发布 · Vue 3 · TypeScript · Vite · Element Plus