1.获取应用缓存
checkCache() {
// 使用plus.cache.calculate 获取应用的缓存大小
var self = this;
// #ifdef APP-PLUS
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
}
2.清除应用缓存
clearStorage() {
var self = this;
//使用plus.cache.clear 清除应用中的缓存数据
// #ifdef APP-PLUS
plus.cache.clear(function() {});
// #endif
this.checkCache();
}