VUE window本地保存Local Storage

徐卓
2023-12-01
保存:window.localStorage.setItem('名','值');
window.localStorage.setItem('token',backdata.data[2]);
查询:window.localStorage.getItem('名');
window.localStorage.getItem('token');
删除:window.localStorage.clear('名');
window.localStorage.clear('token');
删除所有:window.localStorage.clear();
删除指定:window.localStorage.removeItem('mid');
保存数组,取出数组
var dade = ['周一','周二','周三','周四','周五'];
存:window.localStorage.setItem('123',JSON.stringify(dade));
取:JSON.parse(window.localStorage.getItem('123'));

 

 

 类似资料: