JS获取localstorage已使用容量⁄大小。
function getUseSize() { var size = 0; for (item in window.localStorage) { if (window.localStorage.hasOwnProperty(item)) { size += window.localStorage.getItem(item).length; } } console.log('使用:' + (size / 1024).toFixed(2) + 'KB') } getUseSize();