diff --git a/package/component/src/component/select/index.vue b/package/component/src/component/select/index.vue index 34eb7245..46644989 100644 --- a/package/component/src/component/select/index.vue +++ b/package/component/src/component/select/index.vue @@ -18,6 +18,7 @@ import { watch, nextTick, onUnmounted, + h, } from "vue"; import { LayIcon } from "@layui/icons-vue"; import LayInput from "../input/index.vue"; @@ -79,12 +80,15 @@ var timer: any; const getOption = (nodes: VNode[]) => { nodes ?.filter((item: VNode) => { - console.log(JSON.stringify(item)); return item.children != "v-if"; }) ?.map((item: VNode) => { let component = item.type as Component; if (component.name === LaySelectOption.name) { + if(item.children) { + // @ts-ignore + item.props.label = item.children.default()[0].children; + } options.value.push(item.props); } else { getOption(item.children as VNode[]); diff --git a/package/component/src/component/selectOption/index.vue b/package/component/src/component/selectOption/index.vue index 64256bb1..6fa54f69 100644 --- a/package/component/src/component/selectOption/index.vue +++ b/package/component/src/component/selectOption/index.vue @@ -13,10 +13,11 @@ import { WritableComputedRef, Ref, onMounted, + useSlots } from "vue"; export interface LaySelectOptionProps { - label: string; + label?: string; value: string | number | object; disabled?: boolean; keyword?: string; @@ -29,9 +30,7 @@ const props = withDefaults(defineProps(), { }); const openState: Ref = inject("openState") as Ref; -const selectedValue: WritableComputedRef = inject( - "selectedValue" -) as WritableComputedRef; +const selectedValue: WritableComputedRef = inject("selectedValue") as WritableComputedRef; const searchValue: Ref = inject("searchValue") as Ref; const selectRef: Ref = inject("selectRef") as Ref; const multiple: ComputedRef = inject("multiple") as ComputedRef; diff --git a/package/document-component/src/document/zh-CN/components/select.md b/package/document-component/src/document/zh-CN/components/select.md index 76c5fc26..bcbf0987 100644 --- a/package/document-component/src/document/zh-CN/components/select.md +++ b/package/document-component/src/document/zh-CN/components/select.md @@ -16,7 +16,7 @@ - + 运动