Vue-滑动轮播

查看完整代码直接跳到结尾git链接🔗。

1.项目结构

结构

2.设计组件

2.1 swiper设计

<template>
  <!--id,class用来设计样式;因为我不是很熟悉,所以不做说明。-->
  <div id="r-swiper">
    <div class="swiper" 
      @touchstart="touchStart"
      @touchend="touchEnd"> <!--用来获取点击事件-->
      <slot name="picslot"></slot>
    </div>
  </div>
  <!--之所以平级设计是因为小圆点之后position:absolute是相对于父组件的位置,
  因此想要固定在最上方就要评级设计是的相对id='app'固定-->
  <div class="indicator">
    <div
      v-for="index in swiperItemCount"
      :key="index"
      class="indicator-item"
      :class="{active: index === currentIndex+1}"
    ></div><!--动态绑定,用来显示小圆点-->
  </div>
</template>

2.2 swiper-item设计

<template>
  <!-- 子组件插入图片 -->
  <div class="r-swiper-item">
    <slot></slot>
  </div>
</template>

3.设计样式

3.1 App.vue

<style>

  #app {
   
    overflow: hidden;
    position: relative;
  }
</style>

3.2 swiper

<style scoped>
/* #r-swiper {
  overflow: hidden;
  position: relative;
} */

.swiper {
   
  display: flex;
}
.indicator {
   
  display: flex;
  /*
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值