onlytao
onlytao
  • 发布:2021-01-07 11:48
  • 更新:2023-06-20 09:57
  • 阅读:2378

uniapp scroll-view @refresherrefresh 动态高度 无法触发

分类:uni-app

因为要适配高度,在computed中动态设置了高度,然后下拉刷新的时候,就只能拉很短的距离,无法触发@refresherrefresh方法

关键代码:

         :refresher-threshold="100" @refresherpulling="onPulling" @refresherrefresh="onRefresh" @refresherrestore="onRestore"  
         @refresherabort="onAbort" @scrolltolower="lower" name="contetn " class="bg-white myscroll">  
            <view v-if="isNull" class="flex solid-bottom padding justify-center text-xl">暂无数据</view> ```   

js:
``` javascript  
computed: {  
            style() {  
                let topHeight = this.CustomBar + 60  
                let sys = uni.getSystemInfoSync()  
                let phoneHeight = sys.windowHeight  
                let scrollerHeight = (phoneHeight - topHeight)  
                var style = `height:${scrollerHeight}px;`;  
                console.log(topHeight)  
                console.log(scrollerHeight)  
                return style  
            }  
2021-01-07 11:48 负责人:无 分享
已邀请:
onlytao

onlytao (作者)

有官方技术吗?路过的大佬帮我@一下

  • k***@163.com

    请问一下,现在有解决吗?┭┮﹏┭┮

    2022-09-09 13:53

茄子

茄子

刚遇到同样问题,scrollView的初始高度定义了一个大值,比如600 ,再动态赋值没问题了,页面高度也显示正常

HZH8997

HZH8997

很简单

设置个v-if

等高度算好后 在显示

<scroll-view  
                v-if="filePageCfg.height !== null"  
                scroll-y="true"  
                class="wd-w-100p wd-h-100p"  
                :refresher-triggered="triggered"  
                :refresher-enabled="true"  
                :refresher-threshold="100"  
                @refresherrefresh="onRefresh"  
                @refresherrestore="onRestore"  
                @scrolltolower="lower"  
            >Ï

要回复问题请先登录注册