react 函数组件中使用PullToRefresh报错问题

<PullToRefresh
        damping={50 as any}
        className='pullToRefresh'
        getScrollContainer={() => undefined}
        distanceToRefresh={40}
        style={{
          height: hei,
          overflow: 'auto'
        }}
        indicator={{ deactivate: '下拉刷新' } as any}
        direction={'down' as any}
        refreshing={refreshing as any}
        onRefresh={() => {
          setRefreshing(true)
          setTimeout(() => {
            setRefreshing(false);
            initData()
          }, 1000);
        }}
      >
加上下面代码即可
getScrollContainer={() => undefined}  
distanceToRefresh={40}
获取offsetTop出错
 var engineeType = document.querySelector('#engineeType').clientHeight;
 var pullToRefresh = document.querySelector('.pullToRefresh')['offsetTop'];
 let hei = engineeType - pullToRefresh;
 setTimeout(() => setHei(hei), 0);

 

 

  

posted @ 2020-12-14 15:58  吃鸡小能手  阅读(413)  评论(0编辑  收藏  举报