import { log } from "./log" export class util { /** * 获取本地数据 */ public static getStorage(key:string){ let d = uni.getStorageSync(key) if(util.isNull(d)){ return null } return d } /** * 设置本地数据 */ public static setStorage(key:string,value:string){ uni.setStorageSync(key,value) } /** * 清除本地key数据 */ public static clearStorageForKey(key:string){ let d = util.getStorage(key) if(util.isNull(d)){ log.Error(`${key} is null!`); }else{ util.setStorage(key,null) } } /** * 清除本地数据 */ public static clearAllStorage(){ uni.clearStorageSync() } public static isNull(v:any){ if(v==null||v==undefined||v==""){ return true } return false } }