onLoad() {
//应用缓存
//#ifdef APP-PLUS
plus.cache.calculate(size => {
//size是多少个字节单位是b
if (size < 1024) {
this.cache = size + 'B';
} else if (size / 1024 >= 1 && size / 1024 / 1024 < 1) {
this.cache = Math.floor(size / 1024 * 100) / 100 + 'KB';
} else if (size / 1024 / 1024 >= 1) {
this.cache = Math.floor(size / 1024 / 1024 * 100) / 100 + 'M';
}
})
//#endif
}
//清除应用缓存
methods:{
clear(){
//使用plus.cache.clear 清除应用中的缓存数据
plus.cache.clear(() => {
uni.showToast({
title: '清除成功',
icon: 'none',
success() {
self.cache = '0B'
}
})
})
}
}
uniapp应用缓存(HTML5产业联盟)
最新推荐文章于 2023-05-06 11:00:56 发布