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 🙏

© 2026 – Pkg Stats / Ryan Hefner

swiper-pagination

v1.0.4

Published

这是一个 vue2 版本的分页组件,用于在应用程序中实现分页功能。它的特殊之处在于使用鼠标滚轮、鼠标推拽、甚至触摸屏上下滑动时切换上一页/下一页。

Readme

Introduction

这是一个 vue2 版本的分页组件,用于在应用程序中实现分页功能。它的特殊之处在于使用鼠标滚轮、鼠标推拽、甚至触摸屏上下滑动时切换上一页/下一页。

Install

npm i swiper-pagination

Demo

<template>
  <swiper-pagination
    class="demo"
    :pageNum.sync="pageNum"
    :pageSize="pageSize"
    :total="total"
    :events="events"
    @firstPage="onFirstPage"
    @lastPage="onLastPage"
    @pageChange="onPageChange"
  >
    <ul>
      <li v-for="item in items" :key="item.id">{{ item.text }}</li>
    </ul>
  </swiper-pagination>
</template>

<script>
  import swiperPagination, {
    isTouchScreen,
  } from "swiper-pagination/src/SwiperPagination.vue";

  export default {
    components: {
      "swiper-pagination": swiperPagination,
    },
    data: () => ({
      pageNum: 1,
      pageSize: 10,
      total: 0,
      events: ["wheel", "drag"], // 默认鼠标滚轮滑动、鼠标拖拽翻页
      items: [],
    }),
    beforeMount() {
      // 如果是触屏,则添加触屏专用手指滑动事件翻页
      if (isTouchScreen()) this.events.push("touch");
    },
    async mounted() {
      let res = await this.requestData();
      this.items = res.data;
      this.total = res.count;
    },
    methods: {
      requestData() {
        return new Promise((resolve) => {
          setTimeout(() => {
            resolve({
              data: [
                { id: 1, text: "item1" },
                { id: 2, text: "item2" },
                { id: 3, text: "item3" },
              ],
              count: 100,
            });
          }, 1000);
        });
      },
      onFirstPage() {
        console.log("当前是首页");
      },
      onLastPage() {
        console.log("当前是尾页");
      },
      async onPageChange() {
        let res = await this.requestData();
        this.items = res.data;
        this.total = res.count;
      },
    },
  };
</script>

<style scoped>
  .demo {
    width: 100%;
    height: 100%;
    background-color: gray;
  }

  .demo /deep/ > .current-page {
    background-color: white;
  }
</style>

Document

Props

{
    // 当前页码
    pageNum: {
        type: Number,
        default: 1,
    },
    // 当前页数据条数
    pageSize: {
        type: Number,
        default: 10,
    },
    // 总数据条数
    total: {
        type: Number,
        default: 20,
    },
    // 支持的翻页事件,可以随意组合
    events: {
        type: Array,
        default: () => ["wheel", "drag", "touch"], // wheel:表示支持WEB端鼠标滚轮翻页;move:表示支持WEB端鼠标拖动翻页;touch:表示支持触屏拖动翻页
    },
    // 翻页时是否展示页码遮罩
    pageModal: {
        type: Boolean,
        default: true,
    },
    // 页码遮罩透明度
    pageModalOpacity: {
        type: Number,
        default: 0.35,
    },
    // 动画持续时间,单位:秒
    animationDuration: {
        type: Number,
        default: 0.4,
    },
    // 触发加载上一页/下一页的容器移动高度极限,默认0.25表示当容器上下移动超过自身高度25%时触发
    triggerLimit: {
        type: Number,
        default: 0.25,
    },
    // 上一页/下一页出现的方式
    togglePageType: {
        type: String,
        default: "slide", // slide:滑动出现;instantly:瞬间出现;
    },
},

Events

// 页码改变事件
this.$emit("pageChange", this._pageNum);
// 到达首页事件
this.$emit("firstPage");
// 到达尾页事件
this.$emit("lastPage");