1.真机运行报如下错误:
Uncaught TypeError: mui(...).pullRefresh(...).pullupLoading is not a function
Uncaught TypeError: mui(...).pullRefresh(...).endPullupToRefresh is not a function
Uncaught (in promise) TypeError: mui(...).pullRefresh(...).endPulldownToRefresh is not a function
2.浏览器运行classList in undefined:
mui.js:3305 Uncaught TypeError: Cannot read property 'classList' of undefined
3.源码报错的位置:
打印console.log(this.pullPocket);是undefined
4.代码如下:
---------------------------------app.js---------------------------------
var alarmCtrlUtil = require("./alarm_controller");//引入controller
mui.plusReady(function() {
var viewCount = 4,
alarmUrl,
alarmData={},
// token = plus.push.getClientInfo().token;
token = '147dd880ab673ec4d9de808c62cf3e76';
mui.init({
pullRefresh: {
container: '#pullrefresh',
down: {
contentrefresh: '正在刷新...',
//callback: pulldownRefresh//使用同文件加下方法没问题
callback: alarmCtrlUtil.pulldownRefresh(alarmUrl,alarmData)//使用require进来的方法会报错!
},
up: {
contentrefresh: '正在加载...',
//callback: pullupRefresh//使用同文件加下方法没问题
callback: alarmCtrlUtil.pullupRefresh(alarmUrl,alarmData)//使用require进来的方法会报错!
}
}
});
/**
* 下拉刷新具体业务实现
*/
function pulldownRefresh() {}
/**
* 上拉加载具体业务实现
*/
function pullupRefresh() {}
});//plusReady
if(mui.os.plus) {
mui.plusReady(function() {
setTimeout(function() {
mui('#pullrefresh').pullRefresh().pullupLoading();
}, 1000);
});
} else {
mui.ready(function() {
mui('#pullrefresh').pullRefresh().pullupLoading();
});
}
---------------------------------controller.js----------------------------------------------
var alarmService = require("./alarm_service");//alarm_service.js 是ajax请求数据的方法
var alarmCtrlUtil = {
count:0,
colorArr:['#e84e40', '#ffc107', '#03a9f4', '#9c27b0', '#8bc34a'],
pulldownRefresh: function(url, alarmData) {
var body = document.body,
data;
setTimeout(function() {
var table = body.querySelector('.mui-table-view'),
cells = body.querySelectorAll('.mui-table-view-cell');
table.innerHTML = "";
console.log("------------getdata controller down-----------");
alarmService.getDataPms(url, alarmData).then(function(response) {
data = response.data;
alarmCtrlUtil.createElement(data, "down");
mui('#pullrefresh').pullRefresh().endPulldownToRefresh(); //refresh completed
if(mui.os.plus) {
setTimeout(function() {
mui('#pullrefresh').pullRefresh().refresh(true);
}, 1000);
} else {
mui('#pullrefresh').pullRefresh().refresh(true);
}
alarmCtrlUtil.count = 1;
});
}, 1500);
},
pullupRefresh:function(url, alarmData) {
var body = document.body,
data;
setTimeout(function() {
var table = body.querySelector('.mui-table-view'),
cells = body.querySelectorAll('.mui-table-view-cell');
console.log("------------getdata controller up-----------");
console.log(url);
console.log(alarmData);
alarmService.getDataPms(url, alarmData).then(function(response) {
mui('#pullrefresh').pullRefresh().endPullupToRefresh((++alarmCtrlUtil.count * alarmData.viewCount > response.totalsize)); //参数为true代表没有更多数据了。
data = response.data;
alarmCtrlUtil.createElement(data, 'up');
});
}, 1500);
},
//省略其他
}
module.exports=alarmCtrlUtil;
f***@163.com (作者)
我也不知道怎么回事。反正现在是好的。浏览器上不行,手机上可以。
2017-01-11 16:40
2***@qq.com
在浏览器上不行,手机上就可以???我还没试手机,只是在浏览器上一直报错,就一直郁闷一周还没找出来原因
2017-01-13 10:45