Element carousel跑马灯 轮播图滚动方向不对,无法循环播放

在写公司大屏的时候需要使用element跑马灯组件,但由于只有两个数据,在运行时,是默认先向右滑动到第二个item,当到第二个即最后一个后,会进行反方向即向左滑动到第一个item,不符合产品设计要求,遂将数据两条复制为四条(复制过程省略,导致底部出现四条数据的指示器,如图:
在这里插入图片描述
这里通过样式控制指示器的显示隐藏,代码块省略部分代码,自己根据需求补充即可

<el-carousel height="100%"
             class="warn-carousel-box"
             :class="['carousel-indicator' + curIndex]"
             arrow="never"
             :autoplay="false"
             :loop="true"
             @change="carouselChange">
              <el-carousel-item>
              	……省略
              </el-carousel-item>
</el-carousel>

<sciprt>
	const curIndex = ref(0)
	let carouselChange = (index, preindex) => {
	    console.log(index, preindex);
	    curIndex.value = index
	}
</sciprt>

<style scoped>
.carousel-indicator0,
.carousel-indicator1 {
    :deep(.el-carousel__indicator) {
        &:nth-child(3),
        &:nth-child(4) {
            display: none;
        }
    }
}

.carousel-indicator2,
.carousel-indicator3 {
    :deep(.el-carousel__indicator) {
        &:nth-child(1),
        &:nth-child(2) {
            display: none;
        }
    }
}
<style>

完结

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值