File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,23 @@ export default defineComponent({
34
34
const { pageIndex, prevPage, nextPage, setPageIndex } = usePage ( modelValue . value )
35
35
const { startPlay, stopPlay } = useAutoplay ( nextPage , interval . value )
36
36
37
- const count = useSlots ( ) . default ( ) . filter ( item => typeof item . type !== 'symbol' ) . length
37
+ const getCarouselItems = ( ) => {
38
+ let carouselItems = [ ]
39
+ useSlots ( ) . default ( ) . forEach ( item => {
40
+ if ( typeof item . type !== 'symbol' ) {
41
+ carouselItems . push ( item )
42
+ } else {
43
+ if ( Symbol . keyFor ( item . type ) === 'v-fgt' ) {
44
+ carouselItems = [ ...carouselItems , ...item . children ]
45
+ } else if ( Symbol . keyFor ( item . type ) === 'v-txt' ) {
46
+ console . warn ( '不支持文本节点,需要包裹一层元素标签,比如:item 改成 <div>item</div>' )
47
+ }
48
+ }
49
+ } )
50
+ return carouselItems
51
+ }
52
+
53
+ const count = getCarouselItems ( ) . length
38
54
const defaultFormattedPageIndex = formatPageIndex ( pageIndex . value , count )
39
55
const formattedPageIndex = ref ( defaultFormattedPageIndex )
40
56
You can’t perform that action at this time.
0 commit comments