localStorage存储数组时需要先使用JSON.stringify()转成字符串,取的时候再字符串转数组JSON.parse(). var arr=[1,2,3,4]; localStorage.setItem('key',arr); console.log(localStorage('key'); //打印出字符串:1,2,3,4 正常存储: localStorage.setItem('key',JSON.stringify(arr)); console.log(localStorage…