提交 7bbac70f 编写于 作者: Q qiang

fix: swiper-item use Fragment

上级 a499cab4
......@@ -16,6 +16,7 @@ import {
import { upx2px } from '@dcloudio/uni-api'
import { useCustomEvent, CustomEventTrigger } from '../../helpers/useEvent'
import { useTouchtrack } from '../../helpers/useTouchtrack'
import { flatVNode } from '../../helpers/flatVNode'
const props = {
indicatorDots: {
......@@ -693,7 +694,7 @@ export default /*#__PURE__*/ defineComponent({
return () => {
const defaultSlots = slots.default && slots.default()
// TODO filter
swiperItems = defaultSlots || []
swiperItems = flatVNode(defaultSlots)
return (
<uni-swiper ref={rootRef}>
<div ref={slidesWrapperRef} class="uni-swiper-wrapper">
......@@ -703,7 +704,7 @@ export default /*#__PURE__*/ defineComponent({
class="uni-swiper-slide-frame"
style={slideFrameStyle.value}
>
{swiperItems}
{defaultSlots}
</div>
</div>
{props.indicatorDots && (
......
import { Fragment, VNode, isVNode } from 'vue'
export function flatVNode(nodes: any): VNode[] {
const array: VNode[] = []
if (Array.isArray(nodes)) {
nodes.forEach((vnode) => {
if (isVNode(vnode)) {
if (vnode.type === Fragment) {
array.push(...flatVNode(vnode.children))
} else {
array.push(vnode)
}
}
})
}
return array
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册