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()
				}
			}
相关推荐
芬兰y7 分钟前
VUE 带有搜索功能的穿梭框(简单demo)
前端·javascript·vue.js
好果不榨汁14 分钟前
qiankun 路由选择不同模式如何书写不同的配置
前端·vue.js
小蜜蜂dry14 分钟前
Fetch 笔记
前端·javascript
拾光拾趣录15 分钟前
列表分页中的快速翻页竞态问题
前端·javascript
小old弟16 分钟前
vue3,你看setup设计详解,也是个人才
前端
Lefan20 分钟前
一文了解什么是Dart
前端·flutter·dart
Patrick_Wilson25 分钟前
青苔漫染待客迟
前端·设计模式·架构
写不出来就跑路1 小时前
基于 Vue 3 的智能聊天界面实现:从 UI 到流式响应全解析
前端·vue.js·ui
OpenTiny社区1 小时前
盘点字体性能优化方案
前端·javascript
FogLetter1 小时前
深入浅出React Hooks:useEffect那些事儿
前端·javascript