Solve the problem that the scroll-view refresh bar cannot be restored normally after the WeChat applet and uni-app pull-down refresh

About scroll-view, in Uni-app and applet

      refresher-triggered="{
   
   {triggered}}"
      bindrefresherpulling="onPulling"
      bindrefresherrefresh="onRefresh"
      bindrefresherrestore="onRestore"

1. Regardless of the value of triggered, pulling down in the interface will trigger onRefresh, but it will not automatically change the triggered value (two-way binding is not possible, this is the root cause of the problem);
2. After onRefresh is executed, onRestore (reset ) will not be triggered automatically ) (This is the manifestation of the problem), so that the refresh icon is always displayed, and it must be triggered from true to false to trigger onRestore and hide the refresh icon;

So when we execute onRefresh, we need to judge whether it is refreshing. If yes, do not execute refresh and return directly. If not, execute the refresh method and set the triggered value to true!!!
Finally schedule the schedule, and then set the triggerde Is false, and then this will reset itself by calling onRestore after refreshing, the code is as follows

自己先定义Isfreshing=false
onRefresh() { 
        if (this.Isfreshing) return;  
        this.Isfreshing = true;  
        if (!this.triggered)//保证刷新状态下,triggered为true  
            this.triggered = true;  
        setTimeout(() => {  
            this.triggered = false;//触发onRestore,关闭刷新图标  
            this.Isfreshing = false;  
        }, 1200)  
      },
      },

When encountering the problems of WeChat applet development, most of the reasons may be caused by the inability to two-way binding. When encountering generally smaller problems, consider writing your own function methods to try to solve the value changes.

Guess you like

Origin blog.csdn.net/weixin_43722571/article/details/112554726