Skip to content

Commit

Permalink
fix(element): fix select label error (#2202)
Browse files Browse the repository at this point in the history
* fix(element): fix select label error

* feat(element): add form layout inline support
  • Loading branch information
muuyao authored Sep 21, 2021
1 parent 94a6ffc commit c8b513e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
5 changes: 3 additions & 2 deletions packages/element/docs/demos/guide/select/template-async.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
},
},
]"
:enum="[
:dataSource="[
{ label: '发请求1', value: 1 },
{ label: '发请求2', value: 2 },
]"
/>
<Field
name="[Select]"
name="select"
title="异步选择框"
:decorator="[FormItem]"
:component="[
Expand Down Expand Up @@ -57,6 +57,7 @@ const form = createForm({
useAsyncDataSource('select', async (field) => {
const linkage = field.query('linkage').get('value')
if (!linkage) return []
return new Promise((resolve) => {
setTimeout(() => {
if (linkage === 1) {
Expand Down
6 changes: 6 additions & 0 deletions packages/element/src/form-layout/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@import '../__builtins__/styles/common.scss';

.#{$formily-prefix}-form-inline {
display: flex;
flex-wrap: wrap;
}
15 changes: 5 additions & 10 deletions packages/element/src/select/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@ import type {
Option as ElOptionProps,
} from 'element-ui'
import { Select as ElSelect, Option as ElOption } from 'element-ui'
import { resolveComponent, SlotTypes } from '../__builtins__'
import { resolveComponent } from '../__builtins__'

export type SelectProps = ElSelectProps & {
options?: Array<
Omit<ElOptionProps, 'label'> & {
label: SlotTypes
}
>
options?: Array<ElOptionProps>
}

const SelectOption = defineComponent<SelectProps>({
Expand All @@ -31,10 +27,10 @@ const SelectOption = defineComponent<SelectProps>({
if (typeof option === 'string') {
return h(
ElOption,
{ props: { value: option } },
{ props: { value: option, label: option } },
{
default: () => [
resolveComponent(slots?.option ?? option, { option }),
resolveComponent(slots?.option, { option }),
],
}
)
Expand All @@ -44,12 +40,11 @@ const SelectOption = defineComponent<SelectProps>({
{
props: {
...option,
label: '',
},
},
{
default: () => [
resolveComponent(slots?.option ?? option.label, {
resolveComponent(slots?.option, {
option,
}),
],
Expand Down

0 comments on commit c8b513e

Please sign in to comment.