<template>
<view class="">
<view class="Dynamic_text">
<scroll-view class="ul" scroll-y :scroll-into-view="lastItemView" scroll-with-animation>
<view v-for="(item,idx) in dataList" :key='idx' :id="'gift'+idx" style="">
<view class="li" v-if="item!=''">
<text class="sname">{{item}}</text>
</view>
</view>
</scroll-view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
lastItemView: null,
scrollTimeTask: null,
dataList: [''],
}
},
created() {
},
onHide() {
if (this.scrollTimeTask) {
clearInterval(this.scrollTimeTask)
this.scrollTimeTask = null
}
},
mounted() {
this.autoScrollset()
},
methods: {
autoScrollset() {
let idx = 0
if (this.scrollTimeTask) {
clearInterval(this.scrollTimeTask)
this.scrollTimeTask = null
}
this.scrollTimeTask = setInterval(() => {
let target = '列表' + idx
this.lastItemView = `gift${idx}`
this.dataList.push(target)
idx++
}, 500)
},
},
}
</script>
<style lang="scss" scoped>
.Dynamic_text {
.ul {
height: 500px;
.li {
padding: 40rpx 0rpx 40rpx;
background: rgba(0, 0, 0, 0.5);
opacity: 1;
border-radius: 6px;
overflow: hidden;
margin-bottom: 20rpx;
line-height: 48rpx;
padding: 16rpx 20rpx 10rpx 20rpx;
display: flex;
justify-content: flex-start;
align-content: center;
color: #fff;
}
}
}
</style>