存储 storage 大小测试 浏览器 5M 手机端没限制

(function() {
var test = '0123456789';
var add = function(num) {
num += num;
if(num.length == 10240) {
test = num;
return;
}
add(num);
}
add(test);
var sum = test;
var show = setInterval(function(){
sum += test;
try {
plus.storage.removeItem('test');
plus.storage.setItem('test', sum);
console.log(sum.length / 1024 + 'KB');
} catch(e) {
alert(sum.length / 1024 + 'KB超出最大限制');
clearInterval(show);
}
}, 0.1)

})()

posted @ 2020-06-19 08:50  mrt_yy  阅读(308)  评论(0编辑  收藏  举报