关于uni-app中 生成app中使用时产生的缓存清除方式
是在uni-app 打包的app 的环境下才有效果// 使用plus.cache.calculate 获取应用的缓存大小,var self=this;plus.cache.calculate( function ( size ) { //size是多少个字节单位是b//你可以做下面相应的处理if(size<1024){se...
·
是在uni-app 打包的app 的环境下才有效果
// 使用plus.cache.calculate 获取应用的缓存大小,
var self=this;
plus.cache.calculate( function ( size ) { //size是多少个字节单位是b
//你可以做下面相应的处理
if(size<1024){
self.xxx=size+'B';
}
else if(size/1024>=1 && size/1024/1024<1){
self.xxx= Math.floor(size/1024*100)/100+'KB';
}
else if(size/1024/1024>=1){
self.xxx=Math.floor(size/1024/1024*100)/100+'M';
}
//可以询问用户是否删除
uni.showModal({
title:'提示',
content:'确定清除缓存吗?',
success(res) {
// 用户确定要删除
if(res.confirm){
//使用plus.cache.clear 清除应用中的缓存数据 这里清除后还要二十几KB没有清除,达不到全部清除
plus.cache.clear( function () {
uni.showToast({
title:'清除成功',
icon:'none',
success() {
//成功后处理
}
})
});
}
}
})
});
更多推荐
已为社区贡献6条内容
所有评论(0)