npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@retailwe/ui-swiper

v0.0.10

Published

## 引入

Downloads

18

Readme

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 | 滑动动画时长| number | 500 | - | | autoplay | 是否自动切换 | boolean | false | - | | interval | 自动切换时间间隔 | number | 5000 | - | | circular | 是否采用衔接滑动(循环)| boolean | true | - | | mode | 面板指示类型 | string | '' | 点-'dot'、数字-'number'、左右-'direction' | | dots | 指示点数组,仅当modedot时有效 | array | - | 数组结构为{type: string, value: string}, type可选值img/icon/text | | current | 当前展示图片的索引 | number | 0 | - | | maxHeight | swiper最大高度 | number | 300 | 单位是rpx | | imageMode | 图片填充模式,参考原生image的mode属性 | string | aspectFill | - | | fullScreen | 是否全屏展示 | boolean | false | - |

Events

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

外部样式类

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