会飞的大猪
会飞的大猪
  • 发布:2020-03-22 11:22
  • 更新:2023-04-20 16:48
  • 阅读:2866

scrollview下拉刷新不会复位是什么情况

分类:uni-app

scrollview下拉刷新不会复位是什么情况,之前还好的 是我哪里改错了吗
编译器版本:2.6.5(v3)
在IOS上调试的

拉下来就一直在那转个不停,不会弹回去的

<template>  
    <view class="content">  
        <!-- #ifdef APP-PLUS -->  
        <view class="status_bar">  
            <view class="top_view"></view>  
        </view>  
        <!-- #endif -->  
        <view class="example-body">  
            <uni-nav-bar :fixed="true" color="#333333" background-color="#FFFFFF" right-icon="scan" @clickRight="scan">  
                <block slot="left">  
                    <picker class="city" @change="PickerChange" :value="index" :range="picker">  
                        <view class="picker">  
                            {{index>-1?picker[index]:'全部'}}  
                        </view>  
                        <uni-icons type="arrowdown" color="#333333" size="22" />  
                    </picker>  

                    <!-- <view class="city">  
                        <view><text class="uni-nav-bar-text">{{ city }}</text></view>  

                    </view> -->  
                </block>  
                <view class="input-view">  
                    <uni-icons class="input-uni-icon" type="search" size="22" color="#666666" />  
                    <input confirm-type="search" class="nav-bar-input" type="text" placeholder="输入搜索关键词" @confirm="confirm">  
                </view>  
            </uni-nav-bar>  
        </view>  
        <view id="swiper" class="swiperView">  
            <swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000" circular="true">  
                <swiper-item>  
                    <view class="swiper-item" @click="toDetail">  
                        <image src="../../../static/img/homepage/item1.png" mode="scaleToFill"></image>  
                    </view>  
                </swiper-item>  
                <swiper-item>  
                    <view class="swiper-item">  
                        <image src="../../../static/img/homepage/item2.png" mode="scaleToFill"></image>  
                    </view>  
                </swiper-item>  
                <swiper-item>  
                    <view class="swiper-item">  
                        <image src="../../../static/img/homepage/item3.png" mode="scaleToFill"></image>  
                    </view>  
                </swiper-item>  
            </swiper>  
        </view>  
        <scroll-view scroll-y="true" enable-back-to-top="true" show-scrollbar="false" refresher-enabled="true" :refresher-triggered="triggered"  
         :refresher-threshold="45" refresher-background="#eee" @refresherpulling="onPulling" @refresherrefresh="onRefresh"  
         @refresherrestore="onRestore" @refresherabort="onAbort" @scrolltolower="loadMore">  
            <view id="waterfull" class="waterfall">  
                <waterfall :list="list"></waterfall>  
            </view>  
        </scroll-view>  

    </view>  
</template>  

<script>  
    var _self,pageNumber=1,pageSize=10;  
    import uniIcons from '@/components/uni-icons/uni-icons.vue'  
    import uniNavBar from "@/components/uni-nav-bar/uni-nav-bar.vue"  
    import waterfall from '@/components/xi-waterfall/xi-waterfall.vue'  
    export default {  
        components: {  
            uniIcons,  
            uniNavBar,  
            waterfall  
        },  
        data() {  
            return {  
                index: -1,  
                picker: ['北京', '上海', '温州'],  
                city: '北京',  
                scrollTop: 0,  
                triggered: false,  
                old: {  
                    scrollTop: 0  
                },  
                list: [],  
                data: [{  
                    img: "http://pic1.win4000.com/wallpaper/2018-03-28/5abafe0c311e6.jpg",  
                    id: "1084",  
                    isLiked: false,  
                    likeCount: 0,  
                    name: "笑饮孤鸿",  
                    photo: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1576173486008&di=68514e7684d0753c5100994fae6456cb&imgtype=0&src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F201612%2F07%2F20161207195613_xuEFP.thumb.700_0.jpeg",  
                    title: "虽然你我会下落不明",  
                }]  
            };  
        },  
        onLoad() {  
            _self = this;  
            this.onRefresh();  
        },  
        onReachBottom() {  
            // this.loadMore();  
        },  
        methods: {  
            PickerChange(e) {  
                this.index = e.detail.value  
            },  
            showCity() {  
                uni.showToast({  
                    title: '选择城市'  
                })  
            },  
            scan() {  
                uni.showToast({  
                    title: '扫码'  
                })  
            },  
            confirm() {  
                uni.showToast({  
                    title: '搜索'  
                })  
            },  
            toDetail(){  
                uni.navigateTo({  
                    url:'../../detail/release/release?id=1'  
                })  
            },  
            onPulling(e) {  

            },  
            onRefresh() {  
                //pageNumber++;  
                if (this._freshing) {  
                    uni.showToast({  
                        title:'请勿重复刷新',  
                        icon:'loading'  
                    })  
                    return;  
                }  
                this._freshing = true;  
                uni.request({  
                    //这里是拿数据  
                });  
                setTimeout(() => {  
                    this.triggered = false;  
                    this._freshing = false;  
                }, 1000)  
            },  
            onRestore() {  
                this.triggered = 'restore'; // 需要重置  
            },  
            onAbort() {  

            },  
            insertData() {  
                this.list = this.list.concat(this.data);  
            },  
            loadMore:()=>{  
                console.log(1);  
                uni.showNavigationBarLoading();  
                uni.redirectTo({  
                    url: 'ip/article/query?page='+page,  
                    success: res => {  
                        uni.hideNavigationBarLoading();  
                        page++;  
                    },  
                    fail: () => {},  
                    complete: () => {}  
                });  

            }  
        }  
    };  
</script>  
2020-03-22 11:22 负责人:无 分享
已邀请:
9***@qq.com

9***@qq.com

同问,我也遇到这个问题了

4***@qq.com

4***@qq.com

this.triggered = 'restore'; // 需要重置

triggered 是boolean ,要想复原,得再setTimeOut前,把triggered 搞成true,组件不会自动给triggered 给回正

我们都以为,绑定了,就双向绑定了

惯性思维了

refresh(){
this.triggered=true;
console.log("下拉了");
setTimeout(()=>{
console.log("加载完了");
this.triggered=false
},1000)
},

wwwzzz

wwwzzz

楼主 有遇到ios点击顶部状态栏滚动条无法返回顶部问题吗

要回复问题请先登录注册