Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
monorepo
/
venus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit b2c117f5
authored
Sep 30, 2024
by
LinaBell
Committed by
GitHub
Sep 30, 2024
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
chore: demo of customizing form layout using tailwind (#4549)
1 parent
01391ee5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
100 additions
and
0 deletions
playground/src/views/examples/form/basic.vue
playground/src/views/examples/form/basic.vue
View file @
b2c117f
...
@@ -223,6 +223,102 @@ const [BaseForm, baseFormApi] = useVbenForm({
...
@@ -223,6 +223,102 @@ const [BaseForm, baseFormApi] = useVbenForm({
wrapperClass
:
'grid-cols-1 md:grid-cols-2 lg:grid-cols-3'
,
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
>
)
{
function
onSubmit
(
values
:
Record
<
string
,
any
>
)
{
message
.
success
({
message
.
success
({
content
:
`form values:
${
JSON
.
stringify
(
values
)}
`
,
content
:
`form values:
${
JSON
.
stringify
(
values
)}
`
,
...
@@ -256,6 +352,7 @@ function handleSetFormValue() {
...
@@ -256,6 +352,7 @@ function handleSetFormValue() {
<
template
>
<
template
>
<Page
<Page
content-class=
"flex flex-col gap-4"
description=
"表单组件基础示例,请注意,该页面用到的参数代码会添加一些简单注释,方便理解,请仔细查看。"
description=
"表单组件基础示例,请注意,该页面用到的参数代码会添加一些简单注释,方便理解,请仔细查看。"
title=
"表单组件"
title=
"表单组件"
>
>
...
@@ -265,5 +362,8 @@ function handleSetFormValue() {
...
@@ -265,5 +362,8 @@ function handleSetFormValue() {
</
template
>
</
template
>
<BaseForm
/>
<BaseForm
/>
</Card>
</Card>
<Card
title=
"使用tailwind自定义布局"
>
<CustomLayoutForm
/>
</Card>
</Page>
</Page>
</template>
</template>
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment