🐛(select and tab): 修复插槽解析逻辑 (优化速度)
This commit is contained in:
parent
21d8d05032
commit
e8078f76b1
@ -71,20 +71,18 @@ const options = ref<any>([]);
|
|||||||
var timer: any;
|
var timer: any;
|
||||||
|
|
||||||
const getOption = (nodes: VNode[], newOptions: any[]) => {
|
const getOption = (nodes: VNode[], newOptions: any[]) => {
|
||||||
const showNodes = nodes?.filter((item: VNode) => {
|
nodes?.map((item) => {
|
||||||
return item.children != "v-if";
|
|
||||||
});
|
|
||||||
|
|
||||||
showNodes?.map((item: VNode) => {
|
|
||||||
let component = item.type as Component;
|
let component = item.type as Component;
|
||||||
if (component.name === LaySelectOption.name) {
|
if(item.type.toString() == "Symbol(Fragment)") {
|
||||||
if (item.children) {
|
|
||||||
// @ts-ignore
|
|
||||||
item.props.label = item.children.default()[0].children;
|
|
||||||
}
|
|
||||||
newOptions.push(item.props);
|
|
||||||
} else {
|
|
||||||
getOption(item.children as VNode[], newOptions);
|
getOption(item.children as VNode[], newOptions);
|
||||||
|
} else {
|
||||||
|
if (component.name == LaySelectOption.name) {
|
||||||
|
if (item.children) {
|
||||||
|
// @ts-ignore
|
||||||
|
item.props.label = item.children.default()[0].children;
|
||||||
|
}
|
||||||
|
newOptions.push(item.props);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -25,7 +25,7 @@ import {
|
|||||||
reactive,
|
reactive,
|
||||||
h,
|
h,
|
||||||
createTextVNode,
|
createTextVNode,
|
||||||
Fragment,
|
Fragment
|
||||||
} from "vue";
|
} from "vue";
|
||||||
import { useResizeObserver } from "@vueuse/core";
|
import { useResizeObserver } from "@vueuse/core";
|
||||||
import { TabData, TabInjectKey, TabPosition } from "./interface";
|
import { TabData, TabInjectKey, TabPosition } from "./interface";
|
||||||
@ -45,15 +45,14 @@ const childrens: Ref<VNode[]> = ref([]);
|
|||||||
const tabMap = reactive(new Map<number, TabData>());
|
const tabMap = reactive(new Map<number, TabData>());
|
||||||
|
|
||||||
const setItemInstanceBySlot = function (nodes: VNode[]) {
|
const setItemInstanceBySlot = function (nodes: VNode[]) {
|
||||||
const showNodes = nodes?.filter((item: VNode) => {
|
nodes?.map((item) => {
|
||||||
return item.children != "v-if";
|
|
||||||
});
|
|
||||||
showNodes?.map((item) => {
|
|
||||||
let component = item.type as Component;
|
let component = item.type as Component;
|
||||||
if (component.name != tabItem.name) {
|
if(item.type.toString() == "Symbol(Fragment)") {
|
||||||
setItemInstanceBySlot(item.children as VNode[]);
|
setItemInstanceBySlot(item.children as VNode[]);
|
||||||
} else {
|
} else {
|
||||||
childrens.value.push(item);
|
if (component.name == tabItem.name) {
|
||||||
|
childrens.value.push(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -14,8 +14,7 @@
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<lay-tab v-model="current1">
|
<lay-tab v-model="current1">
|
||||||
<lay-tab-item title="选项一" id="1"><div style="padding:20px">选项一</div></lay-tab-item>
|
<lay-tab-item title="选项一" v-if="true" id="1"><div style="padding:20px">选项一</div></lay-tab-item>
|
||||||
<!-- 注释 -->
|
|
||||||
<lay-tab-item title="选项二" id="2"><div style="padding:20px">选项二</div></lay-tab-item>
|
<lay-tab-item title="选项二" id="2"><div style="padding:20px">选项二</div></lay-tab-item>
|
||||||
</lay-tab>
|
</lay-tab>
|
||||||
</template>
|
</template>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user