我的代碼時(shí)這樣的:var storage = window.localStorage;storage[showPeople] = xml_text;存儲(chǔ)的格式是這樣:我現(xiàn)在想只留一條數(shù)據(jù),將其他數(shù)據(jù)存在Value里,以JSON方式存儲(chǔ)。類似這樣:aaa: {"aaa":"","bbb":"","CCC":""}我自己寫了下,但是有問題,我還會(huì)動(dòng)態(tài)添加一些數(shù)據(jù),當(dāng)頁面刷新時(shí),再添加數(shù)據(jù)時(shí),會(huì)將之前的數(shù)據(jù)清空。var storage = window.localStorage;var obj = {};
obj[showPeople] = xml_text
storage.oXML = JSON.stringify(obj);插入的時(shí)候用+=不知道為什么value前面多了個(gè)undefinedstorage.oXML += JSON.stringify(obj);
請(qǐng)問一個(gè)關(guān)于localStorage存儲(chǔ)的問題?
陪伴而非守候
2018-10-09 13:36:43