Swiper组件希望每个Swiper.Item可以根据内容高度自适应
Opened this issue · 3 comments
xiaoliu1990 commented
Version of antd-mobile
5.33.2
What is this feature about?
https://codesandbox.io/p/sandbox/modest-ully-mdvwj3?file=%2Fapp.tsx%3A7%2C73
参考地址,目前Swiper组件每个Swiper.Item的高度都是统一的,如果有多个Swiper.Item,某一个内容特别多,导致高度过高,另外一个内容少,高度按照最高的来,内容少的就会显得很空旷,例如做应用管理,首屏只显示2排,超过的点击首屏的更多按钮切换Swiper到第二页,如果第二页有4排,那首屏两排底部就会有两排高度的空白,这样体验不好。能不能通过某个参数控制是统一高度还是每个Swiper.Item高度自适应。
ycshill commented
我也遇到了这个问题,希望支持
ycshill commented
你现在怎么解决的呢
Zachary0476 commented
一个临时方案:针对已知高度
1、根据UI稿调整好预期的高度;
const diffHeights = [10, 20, 30 ,40]
2、
<Swiper
...xxx
>
{
[...xxx.map(s => {
return <Swiper.Item
style={{ maxHeight:
${diffHeights[activeIndex]}rem
}}...xxx
>
{
...xxx
}
</Swiper.Item>
})
}
`