vue 新聞列表滾動效果


 

效果如下:

 

 

<template>
<div>
<div class="scroll-wrap">
<ul class="scroll-content" :style="{ top }" @mouseenter="Stop()" @mouseleave="Up()">
<li v-for="item in prizeList" v-bind:key="item.id"><a :href="item.src">{{item.name}}</a></li >
</ul>
</div>
</div>
</template>

<script>
export default {
name: 'complexTable',
data() {
return {
prizeList: [
{name: '城軌采購網', src: 'http://www.railunique.com'},
{name: '天津地鐵電子采購平台', src: 'http://www.railunique.com'},
{name: '南昌地鐵', src: 'http://www.railunique.com'},
{name: '南昌地鐵', src: 'http://www.railunique.com'},
{name: '蘭州地鐵招標信息', src: 'http://www.railunique.com'},
{name: '西安公共資源交易中心', src: 'http://www.railunique.com'},
],
activeIndex: 0,
intnum: undefined
}
},
computed: {
top() {
return -this.activeIndex * 20 + 'px';
}
},

created() {
this.ScrollUp();
},
methods: {
ScrollUp() {
// eslint-disable-next-line no-unused-vars
this.intnum = setInterval(_ => {
if (this.activeIndex < this.prizeList.length) {
this.activeIndex += 1;
} else {
this.activeIndex = 0;
}
}, 1000);
},

Stop() {
clearInterval(this.intnum);
},
Up() {
this.ScrollUp();
}
}
}
</script>
<style>
.scroll-wrap {
height: 150px;
overflow: hidden;
}

.scroll-content {
position: relative;
transition: top 0.5s;
}

.scroll-content p {
line-height: 50px;
text-align: center;
}
</style>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM