li ul vue 滚动显示_vue ul循环滚动的问题

图片描述

想实现首尾相连的滚动效果 滚动是可以 但是不是循环的 滚动到最后一个之后 整个列表又被拉下来了, 要怎样才能实现这种循环连续滚动呢 代码改了无数次 搞了好多天了 还是没弄好 太愁人了 大家指点指点迷津 实在弄不好了

我的代码

网站公告

  • :class="{'prev':prevIndex===index,'current':currentIndex===index||index===currentIndex-1}">

    :to="{path:'/information/notice/noticeDetail',query:{id: item.id}}">

    {{item.title}}

    {{item.createTime}}

更多公告

import { formatDate } from 'tools/dateUtil'

export default {

props: ['notices'],

data() {

return {

activeIndex: 0,

prevIndex: -1,

currentIndex: 0

}

},

mounted() {

setInterval( () => {

if(this.currentIndex < this.notices.length) {

//this.currentIndex += 1;

} else {

}

}, 2000)

},

computed: {

top() {

return - this.activeIndex * 45 + 'px'

},

noticesList() {

return this.notices.map( item => Object.assign(item, {

createTime: formatDate(item.createTime, 0)

}))

}

}

}

@import '~assets/less/index.less';

.scroll {

height: 45px;

line-height: 45px;

border: 1px solid #e6e6e6;

overflow: hidden;

.scroll-wrapper{

width: @pages-width;

margin: 0 auto;

.scroll-lt {

position: relative;

.fl(left);

& > p {

.fl(left);

height: 47px;

line-height: 47px;

box-sizing: border-box;

& > i {

display: inline-block;

vertical-align: middle;

width: 21px;

height: 23px;

background: url(../../../assets/images/index.png) -373px -262px no-repeat;

& + a {

font-size: 16px;

color: @french-grey;

padding: 2px 20px;

border-right: 2px solid #ddd;

}

}

}

& > ul {

.fr(right);

padding-left: 15px;

height: 45px;

//overflow: hidden;

position: relative;

//transition: top 0.5s;

li {

transition:all 0.2s;

width: 910px;

font-size: 14px;

position: absolute;

top: -45px;

&.current {

top: 0;

}

&.prev.current {

top: -45px;

}

& > a {

color: @black-color;

& > span {

.fr(right);

}

}

}

}

}

.scroll-rt {

.fr(right);

}

}

}

img/bVXHVu

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值