判断缓存是否为空优化改为方法
This commit is contained in:
@@ -19,7 +19,6 @@ class CACHE {
|
||||
throw (new Error('请传入缓存name值:index | {name:index}'))
|
||||
return
|
||||
}
|
||||
this._isEmpty=Object.keys(data).length>=2?false:true;
|
||||
for (let i in data) {
|
||||
this[i] = data[i]
|
||||
const canWrite = i.slice(0, 1) !== '_'
|
||||
@@ -31,12 +30,16 @@ class CACHE {
|
||||
}
|
||||
|
||||
}
|
||||
isEmpty(){
|
||||
return Object.keys(this).length>=2?false:true;
|
||||
}
|
||||
get(key) {
|
||||
return this[key]
|
||||
}
|
||||
set(key, val) {
|
||||
this[key] = val
|
||||
uni.setStorageSync(this._name, this)
|
||||
this._isEmpty=false
|
||||
}
|
||||
clear() {
|
||||
Object.keys(this).map(v => {
|
||||
|
||||
Reference in New Issue
Block a user