小程序異步獲取當(dāng)前storage的相關(guān)信息wx.getStorageInfo
wx.getStorageInfo(Object object)
異步獲取當(dāng)前storage的相關(guān)信息。緩存相關(guān)策略請查看 存儲。
以 Promise 風(fēng)格 調(diào)用:支持
小程序插件:不支持
微信 Windows 版:支持
微信 Mac 版:支持
參數(shù)
Object object
屬性 類型 默認(rèn)值 必填 說明
success function 否 接口調(diào)用成功的回調(diào)函數(shù)
fail function 否 接口調(diào)用失敗的回調(diào)函數(shù)
complete function 否 接口調(diào)用結(jié)束的回調(diào)函數(shù)(調(diào)用成功、失敗都會執(zhí)行)
object.success 回調(diào)函數(shù)
參數(shù)
Object object
屬性 類型 說明
keys Array.<string> 當(dāng)前 storage 中所有的 key
currentSize number 當(dāng)前占用的空間大小, 單位 KB
limitSize number 限制的空間大小,單位 KB
示例代碼
wx.getStorageInfo({
success (res) {
console.log(res.keys)
console.log(res.currentSize)
console.log(res.limitSize)
}
})
try {
const res = wx.getStorageInfoSync()
console.log(res.keys)
console.log(res.currentSize)
console.log(res.limitSize)
} catch (e) {
// Do something when catch error
}
作者:大學(xué)生新聞網(wǎng) 來源:大學(xué)生新聞網(wǎng)