Home > Article > WeChat Applet > Detailed explanation of how scroll-view completes list pages
This article mainly introduces the relevant information on the example code of the scroll-view component of the WeChat applet to implement the list page. Introduction to the scroll-view component scroll-view is a scrollable view component provided by the WeChat applet. Its main function is to use To do the pull-up loading that is often seen on mobile phones, friends who need it can refer to the introduction of
scroll-view component
scroll-view is provided by WeChat applet The scrollable view component, its main function is to do the pull-up to load and pull-down to refresh the list page that is often seen on mobile phones! Let's take "Shake out a smile" as an example to explain the component. Use !
Import a new page for the app
First we need to import a new page for our mini program and open the app in the project root directory.json This projectConfiguration fileIn the pagesarrayAdd "pages/allJoke/allJoke" and then set the bottom NavigationIn the list item of "tabBar" ("list") Add:
{ "text": "列表", "pagePath": "pages/allJoke/allJoke", "iconPath": "images/note.png", "selectedIconPath": "images/noteHL.png" },
If you want to know the meaning of the specific configuration, you can refer to the Mini Program Configuration document and I won’t go into details here!
json configuration page
The next step is the configuration page for our new page. Create a new directory such as alljoke under the page directory, then create a new allJoke.json under this directory, and copy the following code to this file. Inside:
{ "navigationBarTitleText": "笑话集锦", "enablePullDownRefresh": true }
Because we need to use the onPullDownRefresh method provided by the applet when doing pull-down refresh later, enablePullDownRefresh must be turned on in the configuration item. The other option is the top title of the page, which you can set at will or not. !
wxml view page
It’s the turn of the view page. Similarly, create a new alljoke.wxml page in the alljoke directory. wxml is the one created by the mini program The view page document type is written like HTML, so it is not difficult for the front-end to get started. If you need to know more about it, you can read the wxml document. Also copy the following code to alljoke.wxml
<view> <view> <scroll-view class="scroll" scroll-top="{{scrollTop}}" style="height:580px;" scroll-y="true" bindscroll="scrll" bindscrolltolower="loadMore"> <view class="block" wx:for="{{listLi}}" wx:for-item="item"> <text>{{item.text}}</text> </view> </scroll-view> </view> <view class="top" hidden="{{hidden}}" catchtap="goTop">⇧</view> </view>
As you can see, we The protagonist scroll-view also makes a grand appearance here! What I brought here is a long list of configurations, let me tell you about the functions of these configurations!
Configuration item | Function |
---|---|
scroll-top | Set the position of the vertical scroll bar. Please pay attention to if it is set The value does not change and the component will not render! |
scroll-y | Allow vertical scrolling |
Callback function triggered when scrolling | ##bindscrolltolower |
Event triggered when scrolling to the bottom |
The above is the detailed content of Detailed explanation of how scroll-view completes list pages. For more information, please follow other related articles on the PHP Chinese website!