1.在需要传值页面储存
//对象 let numberarr = { num1: 1, num2: 2, num3: 3 }; //字符串 let str = 'heoll'; localStorage.setItem('numberarr ', JSON.stringify(numberarr )); localStorage.setItem('str', str);
2.在另一页面获取
let numb = JSON.parse(localStorage.getItem('number')); let strarr = localStorage.getItem('str');
3.删除
//删除某个 localStorage.removeItem('nubmer'); //删除所有 localStorage.clear();