📌  相关文章
📜  如何将对象推送到本地存储数组 - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:13.755000             🧑  作者: Mango

代码示例1
// Get the existing data
var existing = localStorage.getItem('myFavoriteSandwich');

// If no existing data, create an array
// Otherwise, convert the localStorage string to an array
existing = existing ? existing.split(',') : [];

// Add new data to localStorage Array
existing.push('tuna');

// Save back to localStorage
localStorage.setItem('myFavoriteSandwich', existing.toString());