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

wkiwi-lazy-img

v1.0.0

Published

uni-app框架 图片懒加载自定义组件 主要兼容微信小程序 可配置占位图以及图片加载失败占位图

Downloads

0

Readme

wkiwi-lazy-img

uni-app框架 图片懒加载自定义组件 主要兼容微信小程序 可配置占位图以及图片加载失败占位图

背景

​ 小程序原生图片组件 image 提供的图片懒加载功能 lazy-load 限制过多,只针对 page 与 scroll-view 下的 image 有效。

实现思路

使用 uni.createSelectorQuery() 查找节点获取图片距离顶部距离,与页面滚动距离进行比较

使用方法

  1. 安装组件
npm install --save wkiwi-lazy-img
  1. 在页面引入组件 wkiwi-lazy-img
import lazyImg from "../wkiwi-lazy-img/wkiwi-lazy-img.vue";
  1. WXML 文件中引用 wkiwi-lazy-img

    <wkiwi-lazy-imgs  
    :showMenuByLongpress="true" 
    :scrollTop="scrollTop" 
    :index="index"  
    :src="item.avatar" 
    :windowHeight="windowHeight" 
    :distance="windowHeight" 
    mode="aspectFill" 
    placeholder="/static/image/common/lottery-default.png" 
    ></wkiwi-lazy-imgs>
       

    wkiwi-lazy-img 的属性介绍如下:

    | 字段名 | 类型 | 必填 | 描述 | | ------------------- | ------- | ---- | -------------------------------------------| | index | Number | 是 | 下标 | | scrollTop | Number | 是 | 滚动到顶部距离 | | windowHeight | Number | 是 | 屏幕高度 | | distance | Number | 否 | 距离底部多少 PX 开始预加载 | | src | String | 是 | 图片链接 | | placeholder | String | 否 | 占位图片链接 | | mode | String | 否 | 请参考 image 组件 mode 属性 | | webp | Number | 否 | 请参考 image 组件 webp 属性 | | showMenuByLongpress | Boolean | 否 | 请参考 image 组件 show-menu-by-longpress 属性 | | styles | String | 否 | 设置图片样式 |

  2. 更新页面滚动顶部距离


onPageScroll: function(res) { //页面滚动监听
  let _this = this;
  clearTimeout(this.pageScrollTimeoutId);
  this.pageScrollTimeoutId = setTimeout(function() { //节流
    _this.scrollTop = res.scrollTop
  }, 30);
},

wkiwi-lazy-image 外部样式类

image-class, image-container-class