7***@qq.com
7***@qq.com
  • 发布:2016-08-04 13:42
  • 更新:2016-08-22 17:53
  • 阅读:1444

如何在下拉刷新的时候使用plus.storage.setItem

分类:MUI

在下拉刷新的时候使用plus是没用的,但是我使用场景需要下拉刷新的时候写入本地一些数据
如何在下拉刷新的时候使用plus.storage.setItem

2016-08-04 13:42 负责人:无 分享
已邀请:
1***@qq.com

1***@qq.com

同问,希望官网能回复一下

7***@qq.com

7***@qq.com

mui.init({
pullRefresh: {
container: '#pullrefresh',
down: {
function(){
localStorage.setItem(key,value);
}
},
up: {
contentrefresh: '正在加载...',
}
}
});
直接用localstorage.setitem不可以么,这边手打,大小写不知是否正确

1***@qq.com

1***@qq.com

找到办法了(在某些情况下可能失效

//页面载入 mui.init()放在mui.plusReady()后面  
//定义一个空变量Storage  
var Storage = null;  

//将plus.storage类赋予Storage  
mui.plusReady(function(){  
    Storage = plus.storage;  
});  

mui.init({  
    pullRefresh: {  
        container: '#pullrefresh',  
        down: {  
            callback: function(){  
                Storage.setItem('key','value');  
                console.log(JSON.stringify(Storage.getItem('key')));  
                // 输出内容: {"key":"value"}   

                // 执行其他操作....  
            }  
        }  
    }  
});
  • 7***@qq.com (作者)

    应该是加载顺序问题

    mui.plusReady(function() {

    var data=queryStorage(plus.webview.currentWebview().id);

    console.log('----------data'+data);

    if(data!=null){

    var tbodyHtml=piectHtml(data);

    jQuery("#pullrefresh ul").html(tbodyHtml);

    }else{

    if (mui.os.plus) {

    mui.plusReady(function() {

    setTimeout(function() {

    mui('#pullrefresh').pullRefresh().pulldownLoading();

    }, 1000);

    });

    } else {

    mui.plusReady(function() {

    mui('#pullrefresh').pullRefresh().pulldownLoading();

    });

    }

    }

    我现在是这样写

    2016-08-23 02:34

  • 1***@qq.com

    回复 7***@qq.com:你不是要在下拉callback里边使用plus.storage吗.....

    2016-08-23 15:00

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