diff --git a/store/cashe.js b/store/cashe.js index c215605..a513933 100644 --- a/store/cashe.js +++ b/store/cashe.js @@ -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 => {