上代码 (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) })() 浏览器@版本最大LocalStorageChrome 84.0.4147.105最大5MFirefox79.0最大5MEdge最大5MIE最大3120kb,有毒