import React, { useState } from 'react';
import { Swiper, View, Text } from '@ray-js/ray';
export default function VerticalSwiper() {
const [current, setCurrent] = useState(0);
const dataSource = [
{ id: '1', color: '#722ed1', label: '纵向一' },
{ id: '2', color: '#eb2f96', label: '纵向二' },
{ id: '3', color: '#13c2c2', label: '纵向三' },
];
return (
<Swiper
style={{ width: '702rpx', height: '300rpx' }}
vertical
dots
dotColor="rgba(255,255,255,0.4)"
dotActiveColor="#fff"
duration={400}
current={current}
dataSource={dataSource}
renderItem={(item) => (
<View
style={{
width: '100%',
height: '100%',
backgroundColor: item.color,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
<Text style={{ color: '#fff', fontSize: '32rpx' }}>{item.label}</Text>
</View>
)}
onChange={(e) => setCurrent(e.current)}
onAfterChange={(e) => console.log('动画结束:', e.current)}
/>
);
}