Skip to content

jayZOU/lazyload

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lazyload

性能更优越的小程序懒加载库

enter image description here

install

链接下载

Usage

//page.js
import lazyLoad from '../../libs/lazyload';
let lazyload;
Page({
	data: {
		img: []
	},
	onLoad: function () {

		lazyload = new lazyLoad(this, {
			classNote: '.item-',			//循环节点class
			initNum: 5,						//初始化展示多少个节点
			limit: 5						//每次加载多少个节点
		})
	},

	onReady: function () {
		lazyload.observe();
	},
})

初始化完成之后会在data添加__LAZT_LOAD_COUNT字段,用来标识当前加载到第几张图,业务方自行判断节点挂载,例如

//page.wxml

<view>
    <view wx:for="{{img}}" class="item-{{index}}">
        <image style="display: {{index < __LAZT_LOAD_COUNT + 1 ? 'block' : 'none'}}" src="{{item}}"></image>
    </view>
</view>

About

Simple fast and superior performance

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published