Skip to content

Commit

Permalink
chore: demo of customizing form layout using tailwind (#4549)
Browse files Browse the repository at this point in the history
  • Loading branch information
imdap authored Sep 30, 2024
1 parent 01391ee commit b2c117f
Showing 1 changed file with 100 additions and 0 deletions.
100 changes: 100 additions & 0 deletions playground/src/views/examples/form/basic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)}`,
Expand Down Expand Up @@ -256,6 +352,7 @@ function handleSetFormValue() {

<template>
<Page
content-class="flex flex-col gap-4"
description="表单组件基础示例,请注意,该页面用到的参数代码会添加一些简单注释,方便理解,请仔细查看。"
title="表单组件"
>
Expand All @@ -265,5 +362,8 @@ function handleSetFormValue() {
</template>
<BaseForm />
</Card>
<Card title="使用tailwind自定义布局">
<CustomLayoutForm />
</Card>
</Page>
</template>

0 comments on commit b2c117f

Please sign in to comment.