使用JSON.parse之后,某些字段将获得空字符串值。
我使用localStorage.getItem("letter_" + i);
获取数据,然后得到:
{"id":2,"body":"heyyy","attachfilephoto":"","private_attachfilephoto":"de0371e568a0449f29d5d4e644ff20e7|98472274636224c27e2033fdd6c4d790|3adb5e0829e56d8dc1a47134885eaf3a|","short_video_attachfilephoto":"","select_vg_id":""}
在JSON.parse(template);
之后,有下一个:
但是当我单击以打开箭头时,private_attachfilephoto字段将为空字符串:
为什么private_attachfilephoto获取空字符串?
代码部分:
return new Promise((resolve, reject) => {
var templates = [];
for(var i = 1; i <= 3; i++) {
var template = localStorage.getItem("letter_" + i);
console.log(template);
if(template) {
template = JSON.parse(template);
console.log(template);
templates.push(template);
}
}
console.log(templates);
resolve(templates);
});