介绍
这篇文章将为大家详细讲解有关微信小程序中数据管理API的示例分析,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
wx.getStorage(对象)
从本地缓存中异步获取指定关键对应的内容。
对象参数说明:
(tr)参数类型必填说明[/tr]
示例代码:
wx.getStorage ({ ,,,关键:,& # 39;关键# 39; 成功,,,:,函数(res), { ,,,,,,,console.log (res.data) ,,,} }),wx.getStorageSync(关键)
从本地缓存中同步获取指定关键对应的内容。
参数说明:
(tr)参数类型必填说明[/tr]
示例代码:
try { ,,,var value =, wx.getStorageSync(& # 39;关键# 39;),if (值),{ ,,,,,,,//,Do something with return 价值 ,,,} },捕捉(e), { ,,,//,Do something when catch 错误 } wx.getStorageInfo(对象)
异步获取当前储存的相关信息
对象参数说明:
(tr)参数类型必填说明[/tr]
成功返回参数说明:
(tr)参数类型说明[/tr]
示例代码:
wx.getStorageInfo ({ 成功,,,:,函数(res), { ,,,,,,,console.log (res.keys); ,,,,,,,console.log (res.currentSize); ,,,,,,,console.log (res.limitSize); ,,,} })# # # wx.getStorageInfoSync同步获取当前储存的相关信息,*,*示例代码:,* *“javascript try { ,,,var res =, wx.getStorageInfoSync (); ,,,console.log (res.keys); ,,,console.log (res.currentSize); ,,,console.log (res.limitSize); },捕捉(e), { ,,,//,Do something when catch 错误 } wx.removeStorage(对象)
从本地缓存中异步移除指定关键。
对象参数说明:
(tr)参数类型必填说明[/tr]
示例代码:
wx.removeStorage ({ ,,,关键:,& # 39;关键# 39; 成功,,,:,函数(res), { ,,,,,,,console.log (res.data) ,,,} }),wx.removeStorageSync(关键)
从本地缓存中同步移除指定关键。
参数说明:
(tr)参数类型必填说明[/tr]
示例代码:
try { ,,,wx.removeStorageSync(& # 39;关键# 39;) },捕捉(e), { ,,,//,Do something when catch 错误 }
关于“微信小程序中数据管理API的示例分析”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看的到。