uniapp清理缓存

<template> <view class="content"> <view>应用缓存:{{storageSize}}</view> <button type="default" @tap="clearStorage">清除缓存</button> </view> </template> <script> export default { data() { return { storageSize : '' } }, onLoad() { this.getStorageSize(); }, methods:{ getStorageSize:function(){ let that = this; uni.getStorageInfo({ success(res) { console.log(res) console.log(res.keys); console.log(res.limitSize); let size = res.currentSize; if (size < 1024) { that.storageSize = size + ' B'; } else if (size/1024>=1 && size/1024/1024<1) { that.storageSize = Math.floor(size/1024*100)/100 + ' KB'; } else if (size/1024/1024>=1) { that.storageSize = Math.floor(size/1024/1024*100)/100 + ' M'; } } }) }, clearStorage:function (){ let that = this; uni.showModal({ title:'提示', content:'确定清除缓存吗?', confirmText:'立即清除', success(res) { if(res.confirm){ uni.clearStorageSync(); //重新获取并显示清除后的缓存大小 that.getStorageSize(); uni.showToast({ title:'清除成功' }) } } }) } } } </script>
那时候我只有一台录音机也没有电脑 也不敢奢求说唱会让自己的生活变好

浙公网安备 33010602011771号