y7
y7
  • 发布:2015-02-04 03:40
  • 更新:2016-05-31 11:00
  • 阅读:11447

下拉页面偶尔会发生这个错误Cannot read property 'classList' of undefined at js/mui.min.js:2349

分类:MUI

下拉页面偶尔会发生这个错误,不知道什么原因,有时候有有时候没有,是加载顺序的原因吗
不是触发事件时,是打开应用时,因为我首页就是 header+list页面的形式list设置的是下拉和上拉刷新
打开应用偶尔会发生

Uncaught TypeError: Cannot read property 'classList' of undefined at js/mui.min.js:2349

2015-02-04 03:40 负责人:无 分享
已邀请:
DCloud_UNI_FXY

DCloud_UNI_FXY

这个问题一般发生在你在页面开始的时候自动上拉了一次。
如果想自动上拉一次。可以在init的pullrefresh的up里边配置auto:true

mui.init({  
                pullRefresh: {  
                    container: '#pullrefresh',  
                    down: {  
                        callback: pulldownRefresh  
                    },  
                    up: {  
                                                auto:true,//自动上拉一次  
                        contentrefresh: '正在加载...',  
                        callback: pullupRefresh  
                    }  
                }  
            });
failedtocopy

failedtocopy

我尝试使用双webview来做上拉刷新和下拉加载,但是发现样式很难控制。这个页面的头上面有一个标题和一个图片,这样我发现下面的代码
mui.init({
pullRefresh: {
container: '#pullrefresh',
down: {
contentdown:'下拉刷新',
contentover:'释放立即刷新',
contentrefresh:'正在刷新...' ,
callback: pulldownRefresh
},
up: {
contentrefresh: '正在加载...',
contentnomore:'没有更多数据了',
callback: pullupRefresh
}
}
});
必须是在主页面中加入了<header class="mui-bar-nav"></header>才会显示,并且显示的加载标题“下拉刷新”,"释放立即刷新","正在刷新"都在上面如下图,能不能控制它显示的位置呢,截图如下

  • jolynekujo

    请问这个问题解决了吗

    2015-09-27 10:57

  • 淘钱宝

    如何在android里控制位置?

    2016-06-01 10:19

  • failedtocopy

    不好意思,没有解决这个问题

    2017-01-11 18:26

d_cloud

d_cloud

同问

DCloud_UNI_FXY

DCloud_UNI_FXY

把mui.min.js换成mui.js。然后看看具体是哪一行。然后贴出来看看

  • y7 (作者)

    已经换了,只是名字没改,Uncaught TypeError: Cannot read property 'classList' of undefined at js/mui.min.js:2349

    2015-02-11 11:44

  • DCloud_UNI_FXY

    你是不是在刚进入的时候,手动调用了一次上拉加载?如果是的话,setTimeout一下。有可能你手动调用上拉加载时,上拉加载还没完全初始化

    2015-02-11 13:34

王不懒

王不懒

Uncaught TypeError: Cannot read property 'classList' of undefined at js/mui.js:2639

_initPullupRefresh: function() {
this.pulldown = false;
this.pullPocket = this.bottomPocket;
this.pullPocket.classList.add(CLASS_BLOCK);
this.pullPocket.classList.add(CLASS_VISIBILITY);
this.pullCaption = this.bottomCaption;
this.pullLoading = this.bottomLoading;
},

是这个方法

  • DCloud_UNI_FXY

    你是不是初始化的时候,调用了pullupLoading。如果是的话延迟一下执行该语句。

    2015-05-25 21:32

kaiven

kaiven

换成最新版本,同样的问题

kaiven

kaiven

无回复,@DCloud_MUI_new

朋也

朋也 - https://tomoya92.github.io

我也经常碰到,求解答

kaiven

kaiven

@DCloud_MUI_FXY,是的,我确实在plusready中进行上拉的。

kaiven

kaiven

@DCloud_MUI_FXY,经过测试 OK,请问,解释一下为什么会出现这个情况?

  • DCloud_UNI_FXY

    是因为你在plusReady里边自动执行上拉加载的时候,上拉加载还没初始化完。

    可以setTimeout一下。当然建议使用我们提供的auto参数

    2015-07-09 20:00

kaiven

kaiven

你指的是mui.js还没有运行完全吧,了解,感谢!建议官方把这些类似的MUI编程规范/陷阱整理成一个文档,

failedtocopy

failedtocopy

同问这个问题 , 我现在也遇到了,第一次双webview

kaiven

kaiven

up: {
auto:true,//自动上拉一次

这个设置还是有问题的,我现在使用延时来解决

kaiven

kaiven

使用 子视图

failedtocopy

failedtocopy

能说的具体点吗

四月技术伍成才

四月技术伍成才

发现出现上面这个问题 是因为这个代码的区别:

在做下来刷新的时候,通常会在页面加载后进行自动加载数据:
正常代码:

if (mui.os.plus) {  
            mui.plusReady(function() {    
                setTimeout(function() {                    
                    mui('#huo_pullrefresh').pullRefresh().pullupLoading();   
                },1000);  
            });  
        } else {  
            mui.ready(function() {                 
                mui('#huo_pullrefresh').pullRefresh().pullupLoading();            
            });  
        }

但是当你把 mui.plusReady 事件 里的 setTimeout 去掉,直接写成

                    mui.plusReady(function() {    
                  mui('#huo_pullrefresh').pullRefresh().pullupLoading();   
             });  

那么 就会发生以下报错:
Cannot read property 'classList'
不知道为什么,希望官方给个解释。

  • DCloud_UNI_FXY

    下拉刷新初始化的过程是异步的。需要setTimeout一下。保证自动加载在初始化之后

    2015-09-17 15:29

LYD

LYD

同问

该问题目前已经被锁定, 无法添加新回复