.scrollBox(ref="scroll" :class="{animate:animate}" @mouseenter="iEnter" @mouseleave="iLeave")
.left(style="cursor:pointer;" @click="pathJump('notices')" v-for="item in release_notice" :key="item.notice_id")
i.iconfont.icon-gonggao5(style="font-size: 18px;")
.notice(style="font-size: 14px;")
.text {
{
item.title }}
.date {
{
item.date }}
mounted() {
this.timer = setInterval(this.scroll, 2000)
}
data() {
return {
animate: false,
timer: null,
scrollLen: 1,
release_notice: [{
title: '123', date: '2021-11-01'},{
title: '456', date: '2021-11-02'}]
}
}
methods: {
scroll(){
if(!this.release_notice.length || this.release_notice.length < 2){
clearInterval(this.timer)
return false
}
let scroll = this.$refs.scroll;
scroll.style.marginTop = -this.scrollLen * 40 +'px';
this.animate=!this.animate;
let _this = this
let timer = setTimeout(()=>{
let arr = _this.release_notice.slice(0, _this.scrollLen)
for(let i=0;i<_this.scrollLen;i++){
_this.release_notice.push(arr[i]);
}
_this.release_notice.splice(0, _this.scrollLen);
_this.animate=!_this.animate;
scroll.style.marginTop='0px';
clearTimeout(timer)
},500)
},
iEnter(){
clearInterval(this.timer)
},
iLeave(){
this.timer = setInterval(this.scroll, 2000)
}
},
<style scoped lang="scss">
.scrollBox {
&.animate{
transition: all .5s ease 0s;
}
}
</style>