index.vue 1.46 KB
Newer Older
xhw committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
<template>
    <view class="container">
      <swiper 
        class="swiper" 
        indicator-dots="false" 
        autoplay="true" 
        interval="3000" 
        duration="1000" 
        circular="true"
        bindchange="swiperChange">
        <swiper-item class="swiper-item" v-for="(item, index) in imgList" :key="index">
          <image :src="item" class="slide-image" />
        </swiper-item>
      </swiper>
    </view>
  </template>
  
  <script>
  export default {
    data() {
      return {
        imgList: [
            '../../../static/photo/makeWord.png',
            '../../../static/photo/fightingAll.png',
            '../../../static/photo/forwardHouse.png' 
          // 更多图片路径
        ],
      };
    },
    methods: {
        swiperChange(e) {
            const currentIndex = e.detail.current; // 获取当前swiper的索引
            // 根据currentIndex动态调整当前、前一张、后一张图片的样式以实现3D效果
            // 由于直接操作样式较为复杂,建议根据currentIndex修改数据驱动样式的变化
        }
    }
  };
  </script>

<style scoped>
.container {
  width: 100%;
  overflow: hidden;
}
.swiper {
  height: 200px;
  width: 100%;
}
.swiper-item {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 200px;
}
.slide-image {
  width: 80%;
  height: 100%;
  transition: transform 1s;
  transform: scale(0.8); /* 默认状态为稍微缩小,聚焦时放大 */
}
</style>