File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -101,15 +101,24 @@ export const Swiper = React.forwardRef<SwiperRef, Partial<WebSwiperProps>>(
101101 const runTimeSwiper = useCallback ( ( ) => {
102102 const durationNumber =
103103 typeof duration === 'string' ? parseInt ( duration ) : duration
104- const d = typeof autoplay === 'number' ? autoplay : durationNumber
104+ let d = durationNumber
105+ // 优先使用明确设置的数值型自动播放间隔
106+ if ( typeof props . autoPlay === 'number' ) {
107+ d = props . autoPlay
108+ } else if ( typeof autoplay === 'number' ) {
109+ d = autoplay
110+ }
105111 timeoutRef . current = window . setTimeout ( ( ) => {
106112 next ( )
107113 runTimeSwiper ( )
108114 } , d )
109- } , [ autoplay , duration ] )
115+ } , [ props . autoPlay , autoplay , duration ] )
110116
111117 useEffect ( ( ) => {
112- if ( ! autoplay || dragging ) return
118+ // 兼容旧版的 autoPlay 属性
119+ const shouldAutoplay = props . autoPlay || autoplay
120+ if ( ! shouldAutoplay || dragging ) return
121+ // if (!autoplay || dragging) return
113122 runTimeSwiper ( )
114123 return ( ) => {
115124 if ( timeoutRef . current ) window . clearTimeout ( timeoutRef . current )
You can’t perform that action at this time.
0 commit comments