// 清除缓存
clearCache() {
// #ifdef APP-PLUS
var self = this;
//使用plus.cache.clear 清除应用中的缓存数据
plus.cache.clear(function() {
uni.showToast({
title: '清除成功!',
icon: 'none',
success() {
self.cacheSize = '0B';
}
});
});
// #endif
},
// 计算缓存大小
calculate() {
// #ifdef APP-PLUS
let self = this;
plus.cache.calculate(function(size) {
//size是多少个字节 单位b
if (size < 1024) {
self.cacheSize = size + 'B';
} else if (size / 1024 >= 1 && size / 1024 / 1024 < 1) {
self.cacheSize = Math.floor((size / 1024) * 100) / 100 + 'KB';
} else if (size / 1024 / 1024 >= 1) {
self.cacheSize = Math.floor((size / 1024 / 1024) * 100) / 100 + 'M';
}
});
// #endif
},