vue.js+elementUI实现点击左右箭头切换头像功能(类似轮播图)

1.效果图如下

vue.js+elementUI实现点击左右箭头切换头像功能(类似轮播图)_第1张图片

2.vue代码如下

<el-carousel type="card" arrow="always" :loop="false" :initial-index="1"
             indicator-position="none" :autoplay="false">
  <el-carousel-item v-for="(items, index) in item.userInfo1" :key="index">
    <div class="div2">
      <div>
        <div style="position: absolute;" v-show="item.state===0 || item.state===1">
          <img @click="deleteImg(items,item)" src="../../assets/delete.png"
               class="deleteStyle">
        </div>
        <img :src="items.b_img.url" class="headImgStyle">
      </div>
      <div class="nickname">
        {{items.b_nickname}}
      </div>
    </div>
  </el-carousel-item>
</el-carousel>

3.修改的样式

  .el-carousel__item.el-carousel__item--card.is-in-stage {
    text-align: center;
  }
  
/*修改高度*/
  .el-carousel__container {
    height: 100px;
  }

  .van-collapse-item__content {
    padding: 14px 0;
  }
  
/*左右箭头的样式*/
  button.el-carousel__arrow.el-carousel__arrow--left, button.el-carousel__arrow.el-carousel__arrow--right {
    font-size: 12px;
    height: 20px;
    width: 20px;
    background: #A099F0;
  }

你可能感兴趣的:(vue.js+elementUI实现点击左右箭头切换头像功能(类似轮播图))