diff --git a/package/component/src/component/select/index.vue b/package/component/src/component/select/index.vue index f1eb29de..f47787ee 100644 --- a/package/component/src/component/select/index.vue +++ b/package/component/src/component/select/index.vue @@ -15,6 +15,7 @@ import { onMounted, VNode, Component, + watch } from "vue"; import LayInput from "../input/index.vue"; import LayTagInput from "../tagInput/index.vue"; @@ -53,6 +54,7 @@ const props = withDefaults(defineProps(), { const slots = useSlots(); const emits = defineEmits(); const searchValue = ref(""); +const singleLabel = ref(""); const openState: Ref = ref(false); const selectedItem: Ref = ref([]); const options = ref([]); @@ -62,6 +64,17 @@ onMounted(() => { getOption(slots.default()); } Object.assign(options.value, props.items); + + watch(selectedValue, () => { + if (multiple.value) { + // tag-input 格式化 + + } else { + singleLabel.value = options.value.find((item: any) => { + return item.value === selectedValue.value; + })?.label; + } + }, { immediate: true }) }); const getOption = function (nodes: VNode[]) { @@ -98,53 +111,28 @@ provide("multiple", multiple); \ No newline at end of file + diff --git a/package/component/src/component/selectOption/index.vue b/package/component/src/component/selectOption/index.vue index 2b322c98..70b2ce3d 100644 --- a/package/component/src/component/selectOption/index.vue +++ b/package/component/src/component/selectOption/index.vue @@ -31,7 +31,9 @@ const props = withDefaults(defineProps(), { const selectedItem: Ref = inject("selectedItem") as Ref; 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 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 fe40eecf..3a1e2c00 100644 --- a/package/document-component/src/document/zh-CN/components/select.md +++ b/package/document-component/src/document/zh-CN/components/select.md @@ -45,9 +45,9 @@ export default {

- - - + + +