Browse Source

fix(carousel): can not use jsx render children (#7077)

Co-authored-by: banruo <shl@dataqin.com>
pull/7102/head
huiliangShen 1 year ago committed by GitHub
parent
commit
c1454bc7b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      components/_util/vnode.ts

6
components/_util/vnode.ts

@ -1,6 +1,6 @@
import { filterEmpty } from './props-util';
import type { VNode, VNodeProps } from 'vue';
import { cloneVNode } from 'vue';
import { cloneVNode, isVNode } from 'vue';
import warning from './warning';
import type { RefObject } from './createRef';
type NodeProps = Record<string, any> &
@ -40,6 +40,10 @@ export function deepCloneElement<T, U>(
if (Array.isArray(vnode)) {
return vnode.map(item => deepCloneElement(item, nodeProps, override, mergeRef));
} else {
// 需要判断是否为vnode方可进行clone操作
if (!isVNode(vnode)) {
return vnode;
}
const cloned = cloneElement(vnode, nodeProps, override, mergeRef);
if (Array.isArray(cloned.children)) {
cloned.children = deepCloneElement(cloned.children as VNode<T, U>[]);

Loading…
Cancel
Save