element-plus走马灯

实现效果

成都大屏——经济发展
在这里插入图片描述

代码实现

目录结构
在这里插入图片描述


  1. 数据处理
    对于这种张幻灯片包含多个item的,要先对数据进行分组处理
const focusListGroups = computed(() => {
    const groups = []
    const groupSize = 2 // 每组2个
    for (let i = 0; i < state.list.length; i += groupSize) {
      groups.push(state.list.slice(i, i + groupSize))
    }
    return groups
  })

slice用于从数组中提取指定的元素,并将这些元素放入一个新的数组中返回

在这里插入图片描述

  1. 遍历渲染
    要通过2层循环,来遍历
    外层遍历的group相当于若干幻灯片中的一张
    内层的 item相当于一张幻灯片里包含的其中一个元素
    所以,只要2层循环
<el-carousel height="172px" arrow="always" indicator-position="none">
        <el-carousel-item v-for="(group, index) in economyListGroups" :key="'group' + index">
          <div class="groupbox">
            <EconomyItem v-for="(item, index) in group" :key="'item' + index" :data="item"></EconomyItem>
          </div>
        </el-carousel-item>
      </el-carousel>
  1. style
<style scoped>
  :deep(.el-carousel__arrow--left) {
    left: -10px;
  }
  :deep(.el-carousel__arrow--right) {
    right: -3px;
  }
  :deep(.el-carousel__arrow--left i) {
    width: 13px;
    height: 16px;
    background-image: url('@/assets/ScreenLeft/arrowIconLeft.png');
  }
  :deep(.el-carousel__arrow--right i) {
    width: 13px;
    height: 16px;
    background-image: url('@/assets/ScreenLeft/arrowIconRight.png');
  }
  :deep(.el-icon svg) {
    opacity: 0;
  }
</style>
  1. 下面小点点的样式
<style scoped>
  :deep(.el-carousel__indicator--horizontal) {
    top: 200px;
    display: inline-block;
    margin-bottom: -10px;

    /* background-color: red; */

    /* padding: var(--el-carousel-indicator-padding-vertical) var(--el-carousel-indicator-padding-horizontal); */
  }
  :deep(.el-carousel__button) {
    width: 15px;
    height: 3px;
    background-color: #00bdff;
    border-radius: 10px;
  }
</style>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值