如何在localStorage中存取数组

默认localStorage只能存取字符串

那么如何存取数组呢

let newlist = []
localStorage.setItem('recent', JSON.stringify(newlist))
let list = JSON.parse(localStorage.getItem('recent'))

 

转载于:https://www.cnblogs.com/yuanxinru321/p/10476769.html

你可能感兴趣的:(如何在localStorage中存取数组)