vlist是原生js实现的高性能虚拟列表,支持横向和纵向
无
<div class="list" id="list">
<ul></ul>
</div>
var pageIndex = 0;
new Vlist({
container: document.querySelector("#list"),
itemSize: 180,
maxSize: document.documentElement.clientHeight,
loadData: function () {
pageIndex++;
var data = mockData(pageIndex).data
if (data && data.length > 0) {
this.addData(data);
} else {
this.loadEnd()
}
},
// initData: mockData(pageIndex).data,
render: function (itemData, index) {
return `
<div class="item">
<img src="https://img12.360buyimg.com/mobilecms/s372x372_${itemData.img}"/>
<div class="right">
<div class="title">${itemData.t}</div>
<div class="price">¥${itemData.jp / 100}</div>
<div class="buy">立即购买</div>
</div>
</div>
`
}
});
this.addData(data)
this.reloadData(data)
this.showLoading()
this.closeLoading()
this.loadEnd()
更多配置和用法,请参考examples