Skip to content

说明

ex-swiper 需要跟 ex-swiper-item 搭配使用,swiper-item 里面可以放任意内容

基础示例

vue
<template>
  <view style="padding: 40px 0 0 0 ;">
    <ex-swiper
      :swiperItemNum="list.length"
      @change="change"
      swiperStyle="width:220px;height:300px"
    >
      <ex-swiper-item v-for="(item, index) in list" :index="index" :key="index">
        <view
          style="width: 220px;height: 300px;"
          :style="{
            'background-color': item.color,
            opacity: acIndex === index ? 1 : 0.6,
          }"
        >
        </view>
      </ex-swiper-item>
    </ex-swiper>
  </view>
</template>
<script>
export default {
  data() {
    return {
      acIndex: 0,
      list: [
        {
          name: 1,
          color: "blueviolet",
        },
        {
          name: 2,
          color: "greenyellow",
        },
        {
          name: 3,
          color: "palevioletred",
        },
        {
          name: 4,
          color: "lightgray",
        },
        {
          name: 5,
          color: "orange",
        },
      ],
    };
  },
  methods: {
    change(index) {
      this.acIndex = index;
    },
  },
};
</script>
<style lang="scss" scoped></style>

ex-swiper 属性

属性名类型默认值可选值说明
perspectiveString2700px景深
swiperItemNumNumber子容器滑块的数量(必须传递)
swiperStyleString'width:200px;height:300px'swiper 的宽高
acIndexNumber0当前激活的索引
autoplayBooleantruefalse是否自动切换
intervalNumber2000自动切换的间隔时长(ms)
rotateXNumber-15rotateX 旋转角度

ex-swiper-item 属性

属性名类型默认值可选值说明
slideItemOffSetNumber60偏移量
indexNumber索引 必传
showBoxReflectBooleanfalsetrue是否显示倒影
boxReflectString'below 10px linear-gradient(rgba(255,255,255,0),rgba(255,255,255,0.5))'倒影样式

事件

事件名说明
change滑块切换事件