chore: demo of customizing form layout using tailwind (#4549)

pull/48/MERGE
LinaBell 2024-09-30 09:47:16 +08:00 committed by GitHub
parent 01391ee5a1
commit b2c117f544
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 100 additions and 0 deletions

View File

@ -223,6 +223,102 @@ const [BaseForm, baseFormApi] = useVbenForm({
wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3',
});
const [CustomLayoutForm] = useVbenForm({
//
commonConfig: {
//
componentProps: {
class: 'w-full',
},
},
layout: 'horizontal',
schema: [
{
component: 'Input',
componentProps: {
placeholder: '请输入',
},
fieldName: 'field1',
label: '字符串',
},
{
component: 'Input',
componentProps: {
placeholder: '请输入',
},
fieldName: 'field2',
label: '字符串',
},
{
component: 'Input',
componentProps: {
placeholder: '请输入',
},
fieldName: 'field3',
label: '字符串',
},
{
component: 'Input',
componentProps: {
placeholder: '请输入',
},
fieldName: 'field4',
label: '字符串',
},
{
component: 'Input',
componentProps: {
placeholder: '请输入',
},
fieldName: 'field5',
//
formItemClass: 'col-start-3',
label: '前面空了一列',
},
{
component: 'Input',
componentProps: {
placeholder: '请输入',
},
fieldName: 'field6',
//
formItemClass: 'col-span-3',
label: '占满三列',
},
{
component: 'Input',
componentProps: {
placeholder: '请输入',
},
fieldName: 'field7',
// 2
formItemClass: 'col-span-2 col-start-2',
label: '占满2列',
},
{
component: 'Input',
componentProps: {
placeholder: '请输入',
},
fieldName: 'field8',
//
formItemClass: 'col-start-2',
label: '左右留空',
},
{
component: 'Input',
componentProps: {
placeholder: '请输入',
},
fieldName: 'field9',
formItemClass: 'col-start-1',
label: '占满2列',
},
],
//
wrapperClass: 'lg:grid-cols-3',
});
function onSubmit(values: Record<string, any>) {
message.success({
content: `form values: ${JSON.stringify(values)}`,
@ -256,6 +352,7 @@ function handleSetFormValue() {
<template>
<Page
content-class="flex flex-col gap-4"
description="表单组件基础示例,请注意,该页面用到的参数代码会添加一些简单注释,方便理解,请仔细查看。"
title="表单组件"
>
@ -265,5 +362,8 @@ function handleSetFormValue() {
</template>
<BaseForm />
</Card>
<Card title="使用tailwind自定义布局">
<CustomLayoutForm />
</Card>
</Page>
</template>