这是一个创建于 1993 天前的主题,其中的信息可能已经有所发展或是发生改变。
// content 在上面也没有被定义,后端开发人员初学前端,有点蒙蔽。
export const getStore = (params = {}) => {
let {
name,
debug
} = params;
name = keyName + name
let obj = {},
content;
obj = window.sessionStorage.getItem(name);
if (validatenull(obj)) obj = window.localStorage.getItem(name);
if (validatenull(obj)) return;
try {
obj = JSON.parse(obj);
} catch{
return obj;
}
if (debug) {
return obj;
}
if (obj.dataType == 'string') {
content = obj.content;
} else if (obj.dataType == 'number') {
content = Number(obj.content);
} else if (obj.dataType == 'boolean') {
content = eval(obj.content);
} else if (obj.dataType == 'object') {
content = obj.content;
}
return content;
}
4 条回复 • 2019-11-16 01:58:42 +08:00
 |
|
1
DecadentF 2019-10-16 18:01:15 +08:00
就是定义这两个字段
|
 |
|
2
hezhuowei 2019-10-21 18:03:43 +08:00
let obj = {}; let content; 的意思
|
 |
|
3
liaotuo 2019-10-23 11:45:06 +08:00
和 C 语言一样,定义两个变量
|
 |
|
4
xcstream 2019-11-16 01:58:42 +08:00
定义一个空的变量
|