mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix: sort vnode not work (#6100)
This commit is contained in:
parent
6a992793b4
commit
4dc423993d
@ -18,17 +18,16 @@ function flattenVNodes(vnodes: VNode[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type VueInstance = {
|
type VueInstance = {
|
||||||
_vnode: VNode;
|
|
||||||
$vnode: VNode;
|
$vnode: VNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
// sort children instances by vnodes order
|
// sort children instances by vnodes order
|
||||||
export function sortChildren(children: VueInstance[], parent: VueInstance) {
|
export function sortChildren(children: VueInstance[], parent: VueInstance) {
|
||||||
// null on SSR
|
const { componentOptions } = parent.$vnode;
|
||||||
if (!parent._vnode) {
|
if (!componentOptions || !componentOptions.children) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const vnodes = flattenVNodes(parent._vnode.children!);
|
const vnodes = flattenVNodes(componentOptions.children);
|
||||||
children.sort((a, b) => vnodes.indexOf(a.$vnode) - vnodes.indexOf(b.$vnode));
|
children.sort((a, b) => vnodes.indexOf(a.$vnode) - vnodes.indexOf(b.$vnode));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user