当前位置:网站首页>5+api, clear application cache

5+api, clear application cache

2022-06-26 13:19:00 sunly_

//  Clear cache 
clear(){
    
	plus.cache.clear(()=> {
    
		uni.showToast({
    
			title: ' Clean up successful , Please restart APP',
		});
		setTimeout(()=>{
    
			plus.runtime.quit();
		},1500)
		this.getSize();
	});
},
//  Calculate cache size 
getSize() {
    
	plus.cache.calculate((size) => {
    
		if (size == 0) {
    
			this.cacheSize = "0B";
		} else if (size < 1024) {
    
			this.cacheSize = size + "B";
		} else if (size < 1048576) {
    
			this.cacheSize = (size / 1024).toFixed(2) + "KB";
		} else if (size < 1073741824) {
    
			this.cacheSize = (size / 1048576).toFixed(2) + "MB";
		} else {
    
			this.cacheSize = (size / 1073741824).toFixed(2) + "GB";
		}
		console.log(this.cacheSize);
	})
},

Cache The module is used to manage the application cache , adopt plus.cache Get cache management object .

原网站

版权声明
本文为[sunly_]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206261149498116.html