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

ly_paging

v0.0.3

Published

分页函数

Downloads

7

Readme

分页模块

调用url查询数据,根据template模版生成html,渲染到container中

1.安装

npm i --save ly_auto

2.使用

var Paging = require('@yj/paging');
new Paging({
    template: require('./tab.handlebars'),
    url: '/test.json',
    container: '#div1'
});

3.配置项

template: 模版,应为handlebars渲染函数
tpl: 同template
url: 数据查询接口
container:模版渲染目标,注意该目标中原有内容会被清除
autoLoad: 组件初始化后自动查询一次,默认为true
hashSave: 在hash中记录页码,使刷新后仍然保持页码,并支持浏览器后退,默认为true
param:调用查询接口时默认传递pageNo参数,如需传递更多参数,需配置该项,可配置为{}或者function
beforeQuery:function(),查询前的回调函数
afterQuery:function(res) 查询完成的回调函数,res为服务端返回的值
afterRender:function(data)模版渲染完成后的回调函数,data为渲染时使用的数据
beforeRender:function(data)模版渲染前调用,可以在其中对数据进行预处理,回调return false会终止渲染

4.方法

setParam(param): 变更param,参数可以是{}或function
toPage(pageNo, callback):跳到指定页,callback在跳转完成后调用
prev(): 跳到上一页
next(): 跳到下一页
render(data):按照数据渲染模版

5.功能class约定

模版中支持以下功能性class
js-first: 该元素触发跳到首页功能
js-end: 该元素触发跳到末页功能
js-next: 该元素触发下一页功能
js-prev: 该元素触发上一页功能
js-topage: 该元素触发跳到某页功能,页码取data-pagenum-target(该属性应符合jquery选择器规范)属性指向的元素value,如无该属性,取元素文本