Home > Daily Programming > HTML Knowledge > What is the infinite scroll component in Mip

What is the infinite scroll component in Mip

藏色散人
Release: 2018-11-06 17:01:36
Original
3834 people have browsed it

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>
Copy after login

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>
Copy after login

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