这是一个创建于 1722 天前的主题,其中的信息可能已经有所发展或是发生改变。
// 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
![DecadentF](https://cdn.v2ex.com/avatar/ede2/f0c8/412081_normal.png?m=1557995918) |
|
1
DecadentF 2019-10-16 18:01:15 +08:00
就是定义这两个字段
|
![hezhuowei](https://cdn.v2ex.com/gravatar/caa8ecc7b7ac74fa350395eda0f8c8ed?s=48&d=retro) |
|
2
hezhuowei 2019-10-21 18:03:43 +08:00
let obj = {}; let content; 的意思
|
![liaotuo](https://cdn.v2ex.com/avatar/75ef/401a/424183_normal.png?m=1673507330) |
|
3
liaotuo 2019-10-23 11:45:06 +08:00
和 C 语言一样,定义两个变量
|
![xcstream](https://cdn.v2ex.com/avatar/9d55/5d90/116896_normal.png?m=1465363453) |
|
4
xcstream 2019-11-16 01:58:42 +08:00
定义一个空的变量
|