0.0.10 • Published 4 years ago

@retailwe/ui-swiper v0.0.10

Weekly downloads
6
License
-
Repository
-
Last release
4 years ago

swiper 商品图片展示组件

引入

全局引入,在miniprogram根目录下的app.json中配置,局部引入,在需要引入的页面或组件的index.json中配置。

// app.json 或 index.json
"usingComponents": {
  "wr-swiper": "@retailwe/ui-swiper/index"
}

代码演示

基础用法

通过imgSrcs属性传入多张商品图片

<wr-swiper imgSrcs="{{imgSrcs}}"></wr-swiper>
// 模式一
Page({
  data: {
    imgSrcs: [
      'https://inews.gtimg.com/newsapp_bt/0/11292297544/1000',
      'https://inews.gtimg.com/newsapp_bt/0/11292420273/1000',
      'https://inews.gtimg.com/newsapp_bt/0/11292297544/1000',
    ],
  },
  onLoad() {},
  onShow() {},
});
// 模式二
Page({
  data: {
    imgSrcs: [{
      src: 'https://inews.gtimg.com/newsapp_bt/0/11292297544/1000',
      height: 400;
      width: 300
    }
    ],
  },
  onLoad() {},
  onShow() {},
});

点状指示器

<wr-swiper
  imgSrcs="{{imgSrcs}}"
  mode="dot">
</wr-swiper>

箭头指示器

<wr-swiper
  imgSrcs="{{imgSrcs}}"
  mode="direction">
</wr-swiper>

数字指示器

<wr-swiper
  imgSrcs="{{imgSrcs}}"
  mode="number">
</wr-swiper>

点击全屏查看

<wr-swiper
  imgSrcs="{{imgSrcs}}"
  full-screen="{{isFullScreen}}"
  bindtap="onSwiperTap">
</wr-swiper>
Page({
  data: {
    imgSrcs: [
      'https://inews.gtimg.com/newsapp_bt/0/11292297544/1000',
      'https://inews.gtimg.com/newsapp_bt/0/11292420273/1000',
    ],
    isFullScreen: false,
  },
  onSwiperTap() {
    this.setData({
      'isFullScreen': !this.data.isFullScreen,
    });
  },
});

API

Props

参数说明类型默认值说明
imgSrcs商品图片地址数组array[]-
duration滑动动画时长number500-
autoplay是否自动切换booleanfalse-
interval自动切换时间间隔number5000-
circular是否采用衔接滑动(循环)booleantrue-
mode面板指示类型string''点-'dot'、数字-'number'、左右-'direction'
dots指示点数组,仅当modedot时有效array-数组结构为{type: string, value: string}, type可选值img/icon/text
current当前展示图片的索引number0-
maxHeightswiper最大高度number300单位是rpx
imageMode图片填充模式,参考原生image的mode属性stringaspectFill-
fullScreen是否全屏展示booleanfalse-

Events

事件名说明回调参数
tapImage点击图片时触发index,被点击的图片索引
change图片切换时触发index,切换后显示的图片索引

外部样式类

类名说明
wr-class根节点外部样式类
wr-dot-class指示点样式
wr-dot-active-class指示点激活时的样式
0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago