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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ophiuchus/pagination

v1.0.1

Published

### 引入

Downloads

6

Readme

Pagination 分页

引入

import Vue from 'vue';
import Pagination from '@ophiuchus/pagination';

Vue.use(Pagination);

代码演示

基础用法

通过 v-model 来绑定当前页码。

<sf-pagination v-model="currentPage" :total-items="24" :items-per-page="5" />
export default {
  data() {
    return {
      currentPage: 1,
    };
  },
};

简单模式

 将 mode 设置为 simple 来切换到简单模式,此时分页器不会展示具体的页码按钮。

<sf-pagination v-model="currentPage" :page-count="12" mode="simple" />

显示省略号

设置 force-ellipses 后会展示省略号按钮,点击后可以快速跳转。

<sf-pagination
  v-model="currentPage"
  :total-items="125"
  :show-page-size="3"
  force-ellipses
/>

自定义按钮

通过 prev-textnext-text 等插槽来自定义分页按钮的内容。

<sf-pagination v-model="currentPage" :total-items="50" :show-page-size="5">
  <template #prev-text>
    <sf-icon name="arrow-left" />
  </template>
  <template #next-text>
    <sf-icon name="arrow" />
  </template>
  <template #page="{ text }">{ { text } }</template>
</sf-pagination>

API

Props

| 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | | v-model | 当前页码 | number | - | | mode | 显示模式,可选值为 simple | string | multi | | prev-text | 上一页按钮文字 | string | 上一页 | | next-text | 下一页按钮文字 | string | 下一页 | | page-count | 总页数 | number | string | 根据页数计算 | | total-items | 总记录数 | number | string | 0 | | items-per-page | 每页记录数 | number | string | 10 | | show-page-size | 显示的页码个数 | number | string | 5 | | force-ellipses | 是否显示省略号 | boolean | false |

Events

| 事件名 | 说明 | 回调参数 | | ------ | -------------- | -------- | | change | 页码改变时触发 | - |

Slots

| 名称 | 描述 | 参数 | | --- | --- | --- | | page | 自定义页码 | { number: number, text: string, active: boolean } | | prev-text | 自定义上一页按钮文字 | - | | next-text | 自定义下一页按钮文字 | - |

样式变量

组件提供了下列 Less 变量,可用于自定义样式,使用方法请参考主题定制

| 名称 | 默认值 | 描述 | | ------------------------------------------ | ------------------- | ---- | | @pagination-height | 40px | - | | @pagination-font-size | @font-size-md | - | | @pagination-item-width | 36px | - | | @pagination-item-default-color | @blue | - | | @pagination-item-disabled-color | @gray-7 | - | | @pagination-item-disabled-background-color | @background-color | - | | @pagination-background-color | @white | - | | @pagination-desc-color | @gray-7 | - | | @pagination-disabled-opacity | @disabled-opacity | - |