z-paging Documentation

website·Indexed 32 days ago

https://z-paging.zxlee.cn

A 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.

Tokens
24.5K
Snippets
118
Records
207
Agent score
57%

What's inside z-paging

  1. Overview of the Pull-to-Refresh Module

    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.
  2. 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.
  3. 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.
  4. 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.
  5. 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-paging v2.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-paging v2.6.9 or earlier.

  6. Use z-paging-swiper as a container for swiper lists

    When using z-paging within a swiper (for horizontal sliding lists), use z-paging-swiper as 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.
  7. 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.
  8. 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();
        }
    }
  9. Use z-paging in nvue for high-performance lists

    In nvue, z-paging is rendered as a <list /> tag by default to optimize resource recovery for invisible parts, providing better performance than view or scroll-view. Because it uses <list />, all direct children within z-paging must be <list /> compatible components such as <cell /> or <header />.

    Key constraints for nvue lists:

    1. 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.
    2. The v-for directive must be placed directly on the <cell /> tag, not on an element inside it.
    3. Do not use the loop index as the unique :key identifier.
    <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>
  10. Call z-paging methods using refs

    To invoke z-paging methods, assign a ref attribute to the z-paging component (e.g., ref="paging") and call the method via this.$refs.paging.methodName().

    Important Constraint: In the Page's onLoad() method, this.$refs is not available synchronously. To call a z-paging method during page load, wrap the call in a setTimeout with a 1ms delay or use this.$nextTick(). Note that reload() is typically called automatically on page load, so manual invocation is often unnecessary.

    // In onLoad
    onLoad() {
      this.$nextTick(() => {
        this.$refs.paging.someMethod();
      });
    }
  11. 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 is z-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)