Commit 97209913 authored by Friends233's avatar Friends233

文字轮播

parent 06e15acd
...@@ -18,5 +18,5 @@ ...@@ -18,5 +18,5 @@
**金币收集动效:[Collect](http://gitlab2.dui88.com/wangqiang1/best-code/blob/master/src/pages/Collect/index.jsx)** **金币收集动效:[Collect](http://gitlab2.dui88.com/wangqiang1/best-code/blob/master/src/pages/Collect/index.jsx)**
**普通轮播:[SwiperC](http://gitlab2.dui88.com/wangqiang1/best-code/blob/master/src/pages/SwiperC/index.jsx)** **普通轮播(奖品和文字轮播):[SwiperC](http://gitlab2.dui88.com/wangqiang1/best-code/blob/master/src/pages/SwiperC/index.jsx)**
import { Marquee } from "@spark/ui";
import React from "react"; import React from "react";
import { Swiper, SwiperSlide } from 'swiper/react'; import { Swiper, SwiperSlide } from 'swiper/react';
...@@ -13,38 +14,53 @@ const SwiperC = () => { ...@@ -13,38 +14,53 @@ const SwiperC = () => {
} }
}) })
return ( return (
<Swiper <div>
className="prize-swiper" <p>奖品轮播:</p>
// spaceBetween={10} <Swiper
slidesPerView={3} className="prize-swiper"
// slidesOffsetAfter={65} // spaceBetween={10}
autoplay={ slidesPerView={3}
{ // slidesOffsetAfter={65}
delay: 3000, autoplay={
disableOnInteraction: false, {
delay: 3000,
disableOnInteraction: false,
}
} }
} initialSlide={0}
initialSlide={0} // centerInsufficientSlides={prizeInfo.length <= 3}
// centerInsufficientSlides={prizeInfo.length <= 3} centeredSlidesBounds={true}
centeredSlidesBounds={true} observer
observer loop={prizeInfo.length > 3}
loop={prizeInfo.length > 3} >
> {prizeInfo.length ?
{prizeInfo.length ? prizeInfo.map((item, index) => {
prizeInfo.map((item, index) => { const { prizeName, prizeUrl } = item || {}
const { prizeName,prizeUrl } = item || {} return (
return ( <SwiperSlide key={index + 'swiper-1'}>
<SwiperSlide key={index + 'swiper-1'}> <div className="prize">
<div className="prize"> <img className="bg-box" src={prizeUrl} alt=''></img>
<img className="bg-box" src={prizeUrl} alt=''></img> <span className="font"> {prizeName}</span>
<span className="font"> {prizeName}</span> </div>
</div> </SwiperSlide>
</SwiperSlide> )
) }) : ""
}) : "" }
}
</Swiper>
<p>文字轮播:</p>
<div className="Marquee" >
<Marquee
baseData={Array(10).fill('').map((_, i) => '奖品轮播啊啊啊啊' + i)}
time={2000}
renderItem={(s) => {
return <div>{s}</div>
}}
/>
</div>
</Swiper>) </div>
)
} }
export default SwiperC export default SwiperC
\ No newline at end of file
.Marquee {
width: 300px;
height: 100px;
}
.prize-swiper { .prize-swiper {
margin-top: 72px; margin-top: 72px;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment