uniapp无限纵向滚动
在uniapp中,可以使用swiper组件实现无限纵向滚动。
- 在页面中引入swiper组件:
<template>
<view>
<swiper :autoplay="true" :interval="3000" :duration="1000" :circular="true" :vertical="true">
<swiper-item v-for="(item, index) in swiperList" :key="index">
<image :src="item.imgUrl"></image>
</swiper-item>
</swiper>
</view>
</template>
<script>
export default {
data() {
return {
swiperList: [
{ imgUrl: 'https://xxx.com/1.jpg' },
{ imgUrl: 'https://xxx.com/2.jpg' },
{ imgUrl: 'https://xxx.com/3.jpg' },
{ imgUrl: 'https://xxx.com/4.jpg' },
{ imgUrl: 'https://xxx.com/5.jpg' },
],
};
},
};
</script>
- 在swiper组件中设置以下属性:
- autoplay:自动播放
- interval:自动播放间隔时间
- duration:滑动动画时长
- circular:循环播放
- vertical:纵向滑动
- 在swiper-item中遍历数据列表,将每个项的图片渲染出来。
这样就可以实现无限纵向滚动了。如果需要更多的自定义,可以参考uniapp官方文档中swiper组件的其他属性和事件。
原文地址: https://www.cveoy.top/t/topic/bFhS 著作权归作者所有。请勿转载和采集!