国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Table of Contents
##Pull down to refresh
##Load more
##Summary
Home WeChat Applet Mini Program Development A brief discussion on how to implement pull-down refresh and load more effects in mini programs

A brief discussion on how to implement pull-down refresh and load more effects in mini programs

Jun 30, 2021 am 11:33 AM
Pull down to refresh load more Applets WeChat

This article will introduce to you several methods to achieve the pull-down to refresh and load more effects in WeChat mini programs. Almost all apps have pull-down refresh and load more effects. I hope you can master them!

A brief discussion on how to implement pull-down refresh and load more effects in mini programs

【Related learning recommendations: 小program development tutorial

##Pull down to refresh

There are currently two ways that can be thought of to implement pull-down refresh

1. Call the system’s API. The system provides an API interface for pull-down refresh

A brief discussion on how to implement pull-down refresh and load more effects in mini programs

2. Monitor scroll-view and customize pull-down refresh. Do you remember that there is a bindscrolltoupper attribute in scroll-view? If you forget, please review the previous article WeChat Mini Program Practical Chapter - E-commerce (2) When scrolling to the top/left, the scrolltoupper event will be triggered, so we can use this attribute to implement the pull-down refresh function.

Both methods are available. The first one is relatively simple and easy to use. After all, some logic systems have already been processed for you. The second one is suitable for small programs that want to customize the pull-down refresh style. We When explaining e-commerce, just use the first one, which is provided by the system. The main purpose is to teach everyone how to use it. Take the homepage as an example

1. Home.json parameter configuration

"enablePullDownRefresh": true

Which page we need to pull down to refresh, configure the above attribute in the xxx.json file corresponding to that page. This attribute literally means You can also know whether pull-down refresh is allowed. Of course, if you don’t want to configure each configuration to allow pull-down refresh, you can directly configure the above attribute in the window of the global variable app.json, so that the entire project allows pull-down refresh. This must be Added because the system does not have the pull-down refresh function by default

2. home.js

  //下拉刷新
  onPullDownRefresh:function()
  {
    wx.showNavigationBarLoading() //在標題欄中顯示加載
    
    //模擬加載
    setTimeout(function()
    {
      // complete
      wx.hideNavigationBarLoading() //完成停止加載
      wx.stopPullDownRefresh() //停止下拉刷新
    },1500);
  },

A brief discussion on how to implement pull-down refresh and load more effects in mini programs

onPullDownRefresh pull-down refresh event Listen, take a look at the code inside, wx.showNavigationBarLoading() and wx.hideNavigationBarLoading(). These two sentences are used to control the display and hiding of the little chrysanthemum. Since we haven’t explained the network request yet, I simulated it. For network loading, use the setTimeout method to write a time delay method. This method can simulate the time consumed by network loading. Also, when the network loading is completed, we need to stop the pull-down refresh wx.stopPullDownRefresh().

This pull-down refresh function has been completed so far, but it is not perfect yet. It is still a bit weird, that is, there is no animation in the pull-down refresh. Is there any~ I also felt strange at the time, the drop-down package in the WeChat envelope How could refresh be like this? Later, I referred to the code written by others and found a small hole. Let's take a look at the effect after I filled in the hole.

A brief discussion on how to implement pull-down refresh and load more effects in mini programs
How about it? Is it more pleasing to the eye? If you want to know how I added this animation, let me reveal it to you. It’s actually very simple. You only need one sentence of code to configure the following properties in the window in app.json. This is to configure the background color of the entire system. Why do I configure it? The system color will appear in the pull-down refresh. The reason is that the pull-down refresh animation itself has it. However, when we do not configure the background color, the system defaults to white, and the animation is also white, so we cannot see the animation effect. Yes It’s not a bit of a trap, haha~~

"backgroundColor": "#f0145a"

##Load more

There are two ways to load more

  • Call the system API

  • Listen to scroll-view, bindscrolltolowerSlide to the bottom of the monitor

I Let’s take the first implementation method to explain. The processing method is slightly different from the pull-down refresh, but it is similar. Let’s take the homepage as an example

1, home.js

  //加載更多
  onReachBottom: function () {
    console.log('加載更多')
    setTimeout(() => {
      this.setData({
        isHideLoadMore: true,
        recommends: [
          {
            goodId: 7,
            name: 'OLAY玉蘭油精油沐浴露玫瑰滋養(yǎng)二合一450ml',
            url: 'bill',
            imageurl: 'http://mz.djmall.xmisp.cn/files/product/20161213/148162245074.jpg',
            newprice: "¥36.60",
            oldprice: "¥40.00",
          },
          {
            goodId: 10,
            name: '蘭蔻玫瑰清瀅保濕柔膚水嫩膚水化妝水400ml補水保濕溫和不刺激',
            url: 'bill',
            imageurl: 'http://mz.djmall.xmisp.cn/files/product/20161201/148057937593.jpg',
            newprice: "¥30.00",
            oldprice: "¥80.00",
          }, {
            goodId: 11,
            name: 'Lancome/蘭蔻清瑩柔膚爽膚水/粉水400ml補水保濕玫瑰水化妝水',
            url: 'bill',
            imageurl: 'http://mz.djmall.xmisp.cn/files/product/20161201/148057953326.jpg',
            newprice: "¥30.00",
            oldprice: "¥80.00",
          },
          {
            goodId: 12,
            name: '美國CLINIQUE倩碧黃油無油/特效潤膚露125ml',
            url: 'bill',
            imageurl: 'http://mz.djmall.xmisp.cn/files/product/20161201/14805828016.jpg',
            newprice: "¥239.00",
            oldprice: "¥320.00",
          },
          {
            goodId: 13,
            name: '法國LANCOME蘭蔻柔皙輕透隔離防曬乳霜50ML2017年3月到期',
            url: 'bill',
            imageurl: 'http://mz.djmall.xmisp.cn/files/product/20161201/148058014894.jpg',
            newprice: "¥130.00",
            oldprice: "¥180.00",
          },
        ],
      })
    }, 1000)
  }

onReachBottom The bottom event monitoring provided by the system is the same as the pull-down refresh. We also simulate some data and add a time delay event, isHideLoadMore, a custom value to control the display and hiding of the loading control

2. home.wxml

 <view class="weui-loadmore" hidden="{{isHideLoadMore}}">
    <view class="weui-loading"></view>
    <view class="weui-loadmore__tips">正在加載</view>
  </view>

Add the above code at the bottom of home.wxml. This is to load more controls. Loading more benefits will not be as good as pull-down refresh. The system does not Provides loading more control animations, so we need to make it ourselves

3, home.wxss

/*  加載更多   */
.weui-loading {
  margin: 0 5px;
  width: 20px;
  height: 20px;
  display: inline-block;
  vertical-align: middle;
  -webkit-animation: weuiLoading 1s steps(12, end) infinite;
  animation: weuiLoading 1s steps(12, end) infinite;
  background: transparent url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMjAiIGhlaWdodD0iMTIwIiB2aWV3Qm94PSIwIDAgMTAwIDEwMCI+PHBhdGggZmlsbD0ibm9uZSIgZD0iTTAgMGgxMDB2MTAwSDB6Ii8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPS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yb3RhdGUoLTE1MCA0NS45OCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDQkNCQ0IiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTEyMCA0MS4zNCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNEMkQyRDIiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTkwIDM1IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0RBREFEQSIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgtNjAgMjQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTJFMkUyIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKC0zMCAtNS45OCA2NSkiLz48L3N2Zz4=) no-repeat;
  background-size: 100%;
}
.weui-loadmore {
  width: 65%;
  margin: 1.5em auto;
  line-height: 1.6em;
  font-size: 14px;
  text-align: center;
}
.weui-loadmore__tips {
  display: inline-block;
  vertical-align: middle;
}

This is our custom style, the style is very simple, it is a simple loading chrysanthemum , what I want to explain here is setting the background in the weui-loading style, data:image/svg xml;base64What does this mean? Before, we usually set the background and directly add the color. This is another version of the background. How to use it, add a picture, this picture is in base64 format, and is drawn with svg. Of course, you can also directly write the picture path into the url. Okay, let's take a look at the effect!

A brief discussion on how to implement pull-down refresh and load more effects in mini programs

##Summary

That’s it for today. Pull-down refresh and load more are essential knowledge for front-end programs. Almost all There are pull-down to refresh and load more in the APP, so everyone must master it. The main explanation here is the pull-down to refresh and load more APIs that come with the mini program. You can try to challenge it and use the second method to implement it~

For more programming related knowledge, please visit: Programming Video! !

The above is the detailed content of A brief discussion on how to implement pull-down refresh and load more effects in mini programs. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
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

Undress AI Tool

Undress AI Tool

Undress images for free

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.

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

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Is the company's security software causing the application to fail to run? How to troubleshoot and solve it? Is the company's security software causing the application to fail to run? How to troubleshoot and solve it? Apr 19, 2025 pm 04:51 PM

Troubleshooting and solutions to the company's security software that causes some applications to not function properly. Many companies will deploy security software in order to ensure internal network security. ...

The difference between H5 and mini-programs and APPs The difference between H5 and mini-programs and APPs Apr 06, 2025 am 10:42 AM

H5. The main difference between mini programs and APP is: technical architecture: H5 is based on web technology, and mini programs and APP are independent applications. Experience and functions: H5 is light and easy to use, with limited functions; mini programs are lightweight and have good interactiveness; APPs are powerful and have smooth experience. Compatibility: H5 is cross-platform compatible, applets and APPs are restricted by the platform. Development cost: H5 has low development cost, medium mini programs, and highest APP. Applicable scenarios: H5 is suitable for information display, applets are suitable for lightweight applications, and APPs are suitable for complex functions.

What are the development tools for H5 and mini program? What are the development tools for H5 and mini program? Apr 06, 2025 am 09:54 AM

H5 development tools recommendations: VSCode, WebStorm, Atom, Brackets, Sublime Text; Mini Program Development Tools: WeChat Developer Tools, Alipay Mini Program Developer Tools, Baidu Smart Mini Program IDE, Toutiao Mini Program Developer Tools, Taro.

How to choose H5 and applets How to choose H5 and applets Apr 06, 2025 am 10:51 AM

The choice of H5 and applet depends on the requirements. For applications with cross-platform, rapid development and high scalability, choose H5; for applications with native experience, rich functions and platform dependencies, choose applets.

What are the different ways of promoting H5 and mini programs? What are the different ways of promoting H5 and mini programs? Apr 06, 2025 am 11:03 AM

There are differences in the promotion methods of H5 and mini programs: platform dependence: H5 depends on the browser, and mini programs rely on specific platforms (such as WeChat). User experience: The H5 experience is poor, and the mini program provides a smooth experience similar to native applications. Communication method: H5 is spread through links, and mini programs are shared or searched through the platform. H5 promotion methods: social sharing, email marketing, QR code, SEO, paid advertising. Mini program promotion methods: platform promotion, social sharing, offline promotion, ASO, cooperation with other platforms.

The latest news APP ranking recommendation in the currency circle (authoritative release in 2025) The latest news APP ranking recommendation in the currency circle (authoritative release in 2025) Apr 21, 2025 pm 09:33 PM

The best cryptocurrency trading and analysis platforms include: 1. OKX: the world's number one in trading volume, supports multiple transactions, provides AI market analysis and on-chain data monitoring. 2. Binance: The world's largest exchange, providing in-depth market conditions and new currency first-time offerings. 3. Sesame Open Door: Known for spot trading and OTC channels, it provides automated trading strategies. 4. CoinMarketCap: an authoritative market data platform, covering 20,000 currencies. 5. CoinGecko: Known for community sentiment analysis, it provides DeFi and NFT trend monitoring. 6. Non-small account: a domestic market platform, providing analysis of linkage between A-shares and currency markets. 7. On-chain Finance: Focus on blockchain news and update in-depth reports every day. 8. Golden Finance: 24 small

TikTok web version entrance login link address https TikTok web version entrance website free TikTok web version entrance login link address https TikTok web version entrance website free May 22, 2025 pm 04:24 PM

The login portal for the Douyin web version is https://www.douyin.com/. The login steps include: 1. Open the browser; 2. Enter the URL https://www.douyin.com/; 3. Click the "Login" button and select the login method; 4. Enter the account password; 5. Complete login. The web version provides functions such as browsing, searching, interaction, uploading videos and personal homepage management, and has advantages such as large-screen experience, multi-tasking, convenient account management and data statistics.

What are the scam routines of cryptocurrency exchanges? What are the scam routines of cryptocurrency exchanges? Apr 20, 2025 pm 05:06 PM

10 top scams on cryptocurrency exchanges Common scams: fake exchanges, Ponzi capital trading, contract manipulation, fake coin phishing, customer service fraud, etc. Identification points: Check regulatory licenses, check contract addresses, and be wary of high-yield commitments Must be protected: Use only mainstream exchanges (Binance/Coinbase) Enable hardware wallet Reject share private key/verification code Deal with fraud: take screenshots immediately, freeze assets, report on the platform, and report to the police Core principle: Any request for password/transfer is a fraud!

See all articles