z-paging Documentation
website·Indexed 32 days ago
https://z-paging.zxlee.cnA comprehensive pagination component for uni-app that supports custom pull-to-refresh, load-more, virtual lists, and chat-record mode. It provides full-platform compatibility, including nvue and uniapp-x support, with built-in management for empty data states, loading indicators, and back-to-top functionality.
What's inside z-paging
- The Pull-to-Refresh module provides a comprehensive set of configurations for implementing pull-to-refresh functionality. It includes capabilities for managing refresh states, customizing the refresh view, implementing 'second-floor' (pull-down to reveal a hidden area) functionality, and tracking refresh distance and status.
Overview of z-paging pagination component
z-paging is a pagination component for uni-app that provides a low-coupling way to implement pull-down refresh and pull-up load more functionality. It manages pagination logic internally, removing the need for developers to define pagination variables in the page data. Key features include support for virtual lists (rendering millions of items), internationalization, theme switching, chat-style pagination, local pagination, and automatic empty-state image management.Overview of z-paging pagination component
z-paging is a high-performance pagination component for uni-app that provides automated management of pull-down refresh and pull-up load-more functionality. It is designed for cross-platform compatibility and supports large datasets via virtual list algorithms.Overview of z-paging Empty and Load Failure Modules
The z-paging Empty and Load Failure modules provide a unified component to handle both empty data states and request failure states. These two states share the same underlying component and configuration logic.Implement Chat Record Mode in z-paging
The Chat Record Mode module allows developers to create a flicker-free chat history interface. Starting from
z-pagingv2.7.0, this is implemented using a 'list inversion' method, which offers a better user experience and supports integration with virtual lists.Compatibility Warning: The new chat record mode (v2.7.0+) is NOT supported on Android versions below 9 or iOS versions below 15. To support these older systems, you must use
z-pagingv2.6.9 or earlier.Use z-paging-swiper as a container for swiper lists
When using z-paging within a swiper (for horizontal sliding lists), usez-paging-swiperas the root node. It acts as a view container that defaults to full-screen, eliminating the need to manually calculate height when inserting it into a swiper's image/content container.Enable and configure the Back to Top button in z-paging
The Back to Top button allows users to automatically scroll back to the top of the page. By default, this button is hidden and must be enabled via props. Starting from version v2.7.12, when used in 'chat record mode', the default image points downwards and the button automatically scrolls to the bottom instead of the top.Implement page scroll integration for z-paging
When using:use-page-scroll="true", z-paging cannot automatically detect the page's scrollTop or when the bottom is reached. You must manually notify z-paging via page lifecycle events. This can be done using a mixin or by implementing the following methods in your page component.export default { // Triggered by system pull-down refresh onPullDownRefresh() { // Reload the list this.$refs.paging.reload().catch(() => {}); }, // Triggered on page scroll onPageScroll(e) { // Update internal scrollTop to determine if pull-down refresh is allowed this.$refs.paging.updatePageScrollTop(e.scrollTop); // Trigger load more for chat record mode if at the top if (e.scrollTop < 10) { this.$refs.paging.doChatRecordLoadMore(); } }, // Triggered when page reaches bottom onReachBottom() { // Notify z-paging to handle load more data this.$refs.paging.pageReachBottom(); } }Install specific versions of z-paging
z-paging can be installed via npm by specifying the desired version. For non-npm installations, users should refer to the GitHub Releases page.Use z-paging in nvue for high-performance lists
In nvue,
z-pagingis rendered as a<list />tag by default to optimize resource recovery for invisible parts, providing better performance thanvieworscroll-view. Because it uses<list />, all direct children withinz-pagingmust be<list />compatible components such as<cell />or<header />.Key constraints for nvue lists:
- Use
<cell />for list items. Note that<cell />is only for nvue; for cross-platform compatibility (rendering as<cell />in nvue and<view />in vue), use the<z-paging-cell />tag. - The
v-fordirective must be placed directly on the<cell />tag, not on an element inside it. - Do not use the loop
indexas the unique:keyidentifier.
<z-paging ref="paging" v-model="dataList" @query="queryList"> <cell class="item" v-for="(item,index) in dataList" :key="item.id" @click="itemClick(item)"> <text class="item-title">{{item.title}}</text> </cell> </z-paging>- Use
Call z-paging methods using refs
To invoke z-paging methods, assign a
refattribute to the z-paging component (e.g.,ref="paging") and call the method viathis.$refs.paging.methodName().Important Constraint: In the Page's
onLoad()method,this.$refsis not available synchronously. To call a z-paging method during page load, wrap the call in asetTimeoutwith a 1ms delay or usethis.$nextTick(). Note thatreload()is typically called automatically on page load, so manual invocation is often unnecessary.// In onLoad onLoad() { this.$nextTick(() => { this.$refs.paging.someMethod(); }); }Install z-paging mini version
The z-paging mini version is a lightweight alternative to the full version, reducing the package size by approximately 40% by removing non-core features. The component name for this version isz-paging-mini.# 1. Download the zip file # 2. Unzip the contents # 3. Copy the code to the /uni_modules/ directory # (Or copy to /node_modules/ if using npm installation)