search
HomeDaily ProgrammingHTML KnowledgeWhat is the infinite scroll component in Mip

This article mainly introduces to you the infinite scroll component in MIP.

MIP is Mobile Web Page Accelerator. The infinite scroll component in MIP (mip-infinitescroll infinite scroll) means that when the user scrolls to the bottom of the page, more data is loaded asynchronously, which is usually suitable for information recommendation.

This effect is equivalent to when we are shopping on mobile Taobao, when we slide the list of products, new product data will be continuously loaded. Obviously this infinite scroll loading effect is also very common in our daily projects.

It is recommended to refer to the detailed manual: "MIP Documentation Manual"

Below we will give you a detailed introduction to the infinite scroll component in MIP based on the component code.

The code example of the infinite scroll component in MIP is as follows:

<mip-infinitescroll data-src="xxx" template="myTemplate">
    <script type="application/json">
    {
        "rn": 40,
        "pn": 1,
        "prn": 6,
        "pnName": "pn",
        "bufferHeightPx": 40,
        "timeout": 5000,
        "loadingHtml": "更多数据正在路上",
        "loadFailHtml": "数据加载失败啦",
        "loadOverHtml": "没有数据了哦"
    }
    </script>
    <template type="mip-mustache" id="myTemplate">
        <li>
            <mip-img src="{{img}}"
                layout="responsive" width="100" height="100">
            </mip-img>
            <p>序号:{{number}}</p>
        </li>
    </template>
    <div class="mip-infinitescroll-results"></div>
    <div class="bg">
        <div class="mip-infinitescroll-loading"></div>
    </div>
</mip-infinitescroll>

When using the infinite scroll component in the mip file, the following two js scripts must be introduced

<script src="https://c.mipcdn.com/static/v1/mip-infinitescroll/mip-infinitescroll.js"> </script>
<script src="https://c.mipcdn.com/static/v1/mip-mustache/mip-mustache.js"> </script>

Introduction to related attributes:

data-src: asynchronous request data interface (only supports JSONP requests)

template: and template id Corresponding, used to identify the template used. If not set, the

rn in the component sub-node will be taken by default: results number, the total number of results to be displayed. Default value: 20

pn: page number, which page to request. Default value: 1

prn: page result number, the number of data requested for each request. Default value: 6

pnName: Page turning keyword. Default value: pn

bufferHeightPx: Buffer height, request data in advance when it is a certain height from the bottom. Default value: 10

loadingHtml: Prompt copy when loading. Default value: Loading...

loadFailHtml: Prompt copy when loading fails, triggered when the asynchronous request times out or fails. Default value: Loading failed

loadOverHtml: Prompt copy when loading is complete. Default value: Loaded. Default value: Loading completed

timeout: timeout for fetch-jsonp request. The unit is ms and the default value is 5000.

Note:

1. The asynchronous request interface must be HTTPS

2. The asynchronous request interface needs to specify the callback as 'callback'

3. The data format returned by the interface needs to be in the following format:

{    "status": 0, 
    "data": { 
        "items": [{}, {}]
    }
}

Among them, status: 0 indicates that the request is successful. items: is the data that needs to be rendered.

This article is an introduction to the infinite scroll component in MIP. It is also relatively simple and easy to understand. I hope it will be helpful to friends in need!

The above is the detailed content of What is the infinite scroll component in Mip. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment