浏览器LocalStorage大小(win10)

上代码
   (function () {
        if (!window.localStorage) {
            console.log('当前浏览器不支持localStorage!')
        }
        let test = '0123456789';
        let add = function (num) {
            num += num;
            if (num.length == 10240) {
                test = num;
                return;
            }
            add(num);
        }
        add(test);
        let sum = test;
        let show = setInterval(function () {
            sum += test;
            try {
                window.localStorage.removeItem('test');
                window.localStorage.setItem('test', sum);
                console.log(sum.length / 1024)
            } catch (e) {
                console.log("最大容量" + sum.length / 1024)
                clearInterval(show);
            }
        }, 0.1)
    })()
浏览器@版本 最大LocalStorage
Chrome 84.0.4147.105 最大5M
Firefox79.0 最大5M
Edge 最大5M
IE 最大3120kb,有毒

你可能感兴趣的:(localstorage)