uniapp滚动消息列表

两个相同的循环列表,循环滚动

html 复制代码
<view class="winners_list uni-flex uni-column" :animation="animationData">
												<view v-for="(item, index) in winnersList" :key="index" class="li uni-flex uni-column">
													<img :src="item.img" alt="" />
													<view>
														<div class="info">
															<span>
																<text>{{ item.info }}</text>
															</span>
															<span>
																<text>{{ item.date }}</text>
															</span>
														</div>
														<div class="prize_name">
															<text>{{ item.prize }}</text>
														</div>
													</view>
												</view>
											</view>
											<view class="winners_list uni-flex uni-column" :animation="animationData">
												<view v-for="(item, index) in winnersList" :key="index" class="li uni-flex uni-column">
													<img :src="item.img" alt="" />
													<view>
														<div class="info">
															<span>
																<text>{{ item.info }}</text>
															</span>
															<span>
																<text>{{ item.date }}</text>
															</span>
														</div>
														<div class="prize_name">
															<text>{{ item.prize }}</text>
														</div>
													</view>
												</view>
											</view>
javascript 复制代码
   //滚动 
			getHeight(Class) {
				let query = uni.createSelectorQuery().in(this);
				query
					.selectAll(Class)
					.boundingClientRect(data => {
						this.height = data[0].height;
					})
					.exec();
			},
			prizeScroll() {
				let speed = 50;
				let animation = uni.createAnimation({
					duration: this.getHeight('.winners_list') / speed,
					timingFunction: 'linear',
					delay: 0
				});
				this.animation = animation;
			this.timer=setInterval(() => {
				console.log('123');
					if (this.scrollHeight >= this.height) {
						this.stopScroll()
						this.prizeScroll()
					} else {
						this.scrollHeight = this.scrollHeight + 1;
						animation.translateY(-this.scrollHeight).step();
						this.animationData = animation.export();
					}
				}, speed);
			},
			
			// 停止动画
			stopScroll(){
				if(this.timer){
					clearInterval(this.timer)
				}
				this.animation.translateY(0).step();
				this.scrollHeight = 0;
				this.animationData = this.animation.export();
			},
			
			
			
			taBtn(index){
				this.currentIndex=index;
				if(index==1){
					this.$nextTick(()=>{
							this.prizeScroll();
					})
				}else{
					this.stopScroll()
				}
			}
相关推荐
WebInfra10 分钟前
Rspack 2.1 发布:React Compiler 提速 10 倍!
前端
李明卫杭州15 分钟前
CSS 媒体查询详解:一文掌握响应式设计的核心技术
前端
lichenyang4531 小时前
从 H5 按钮到 OpenHarmony 能力调用:我如何理解 ASCF 的运行链路
前端
下家1 小时前
我放弃了 Vue/React,选择自研框架
前端·前端框架
Asize2 小时前
HTML5 Canvas 基础:从按帧动画到 ECharts 数据可视化
前端·javascript·canvas
默_笙2 小时前
🎄 后端给我一堆扁平数据,我 10 行代码把它变成了树
前端·javascript
Mahut2 小时前
我用 Electron + FFmpeg 做了一个本地视频处理工作站 ClipForge
前端·ffmpeg·electron
前端Hardy2 小时前
又一个 AI 神器火了!
前端·javascript·后端
锋行天下2 小时前
我试图优化 Vite 的拆包,结果首屏慢了 10 倍
前端·vue.js·架构
PBitW2 小时前
GPT训练我的第二天,我表示不过如此!!!😕😕😕
前端·javascript·面试