diff --git a/package/component/package.json b/package/component/package.json index 1e8c13bd..ad9b63a5 100644 --- a/package/component/package.json +++ b/package/component/package.json @@ -1,6 +1,6 @@ { "name": "@layui/layui-vue", - "version": "1.6.9-alpha.3", + "version": "1.6.9", "author": "就眠儀式", "license": "MIT", "description": "a component library for Vue 3 base on layui-vue", diff --git a/package/component/src/component/select/index.vue b/package/component/src/component/select/index.vue index dc5d6013..44ee5562 100644 --- a/package/component/src/component/select/index.vue +++ b/package/component/src/component/select/index.vue @@ -16,17 +16,13 @@ import { VNode, Component, watch, - nextTick, onUnmounted, - h, } from "vue"; import { LayIcon } from "@layui/icons-vue"; import LayInput from "../input/index.vue"; import LayTagInput from "../tagInput/index.vue"; import LayDropdown from "../dropdown/index.vue"; -import LaySelectOption, { - LaySelectOptionProps, -} from "../selectOption/index.vue"; +import LaySelectOption, { SelectOptionProps } from "../selectOption/index.vue"; import { SelectSize } from "./interface"; export interface SelectProps { @@ -38,7 +34,7 @@ export interface SelectProps { emptyMessage?: string; modelValue?: any; multiple?: boolean; - items?: LaySelectOptionProps[]; + items?: SelectOptionProps[]; size?: SelectSize; collapseTagsTooltip?: boolean; minCollapsedNum?: number; @@ -77,30 +73,34 @@ const openState: Ref = ref(false); const options = ref([]); var timer: any; -const getOption = (nodes: VNode[]) => { - nodes - ?.filter((item: VNode) => { - 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[]); +const getOption = (nodes: VNode[], newOptions: any[]) => { + const showNodes = nodes?.filter((item: VNode) => { + return item.children != "v-if"; + }); + + showNodes?.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; } - }); + newOptions.push(item.props); + } else { + getOption(item.children as VNode[], newOptions); + } + }); }; const intOption = () => { + const newOptions: any[] = []; if (slots.default) { - getOption(slots.default()); + getOption(slots.default(), newOptions); + } + Object.assign(newOptions, props.items); + if (JSON.stringify(newOptions) != JSON.stringify(options.value)) { + options.value = newOptions; } - Object.assign(options.value, props.items); }; const handleRemove = (value: any) => { @@ -248,4 +248,4 @@ provide("multiple", multiple); - + \ No newline at end of file diff --git a/package/component/src/index.ts b/package/component/src/index.ts index c46e21af..97b4475d 100644 --- a/package/component/src/index.ts +++ b/package/component/src/index.ts @@ -61,7 +61,6 @@ import LayDropdownSubMenu from "./component/dropdownSubMenu/index"; import LayTab from "./component/tab/index"; import LayTabItem from "./component/tabItem/index"; import LayTree from "./component/tree/index"; -import LayTreeSelect from "./component/treeSelect/index"; import LayTable from "./component/table/index"; import LayPage from "./component/page/index"; import LayTransfer from "./component/transfer/index"; @@ -181,7 +180,6 @@ const components: Record = { LaySpace, LayTag, LayTagInput, - LayTreeSelect, }; const install = (app: App, options?: InstallOptions): void => { @@ -278,7 +276,6 @@ export { LaySpace, LayTag, LayTagInput, - LayTreeSelect, install, }; 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 bcbf0987..cf8c3976 100644 --- a/package/document-component/src/document/zh-CN/components/select.md +++ b/package/document-component/src/document/zh-CN/components/select.md @@ -214,7 +214,7 @@ export default { ::: demo