网友真实露脸自拍10p,成人国产精品秘?久久久按摩,国产精品久久久久久无码不卡,成人免费区一区二区三区

小程序模板網

微信小程序1028版本新增:新增數據管理 API

發布時間:2018-03-29 17:34 所屬欄目:小程序開發教程

wx.getStorage(OBJECT)

從本地緩存中異步獲取指定 key 對應的內容。

OBJECT參數說明:

參數 類型 必填 說明
key String 本地緩存中的指定的 key
success Function 接口調用的回調函數,res = {data: key對應的內容}
fail Function 接口調用失敗的回調函數
complete Function 接口調用結束的回調函數(調用成功、失敗都會執行)

示例代碼:

wx.getStorage({
  key: 'key',
  success: function(res) {
      console.log(res.data)
  } 
})

wx.getStorageSync(KEY)

從本地緩存中同步獲取指定 key 對應的內容。

參數說明:

參數 類型 必填 說明
key String 本地緩存中的指定的 key

示例代碼:

try {
  var value = wx.getStorageSync('key')
  if (value) {
      // Do something with return value
  }
} catch (e) {
  // Do something when catch error
}

wx.getStorageInfo(OBJECT)

異步獲取當前storage的相關信息

OBJECT參數說明:

參數 類型 必填 說明
success Function 接口調用的回調函數,詳見返回參數說明
fail Function 接口調用失敗的回調函數
complete Function 接口調用結束的回調函數(調用成功、失敗都會執行)

success返回參數說明:

參數 類型 說明
keys String Array 當前storage中所有的key
currentSize Number 當前占用的空間大小, 單位kb
limitSize Number 限制的空間大小,單位kb

示例代碼:

wx.getStorageInfo({
  success: function(res) {
    console.log(res.keys)
    console.log(res.currentSize)
    console.log(res.limitSize)
  }
})

### wx.getStorageInfoSync

同步獲取當前storage的相關信息

**示例代碼:**

```javascript
try {
  var res = wx.getStorageInfoSync()
  console.log(res.keys)
  console.log(res.currentSize)
  console.log(res.limitSize)
} catch (e) {
  // Do something when catch error
}

wx.removeStorage(OBJECT)

從本地緩存中異步移除指定 key 。

OBJECT參數說明:

參數 類型 必填 說明
key String 本地緩存中的指定的 key
success Function 接口調用的回調函數
fail Function 接口調用失敗的回調函數
complete Function 接口調用結束的回調函數(調用成功、失敗都會執行)

示例代碼:

wx.removeStorage({
  key: 'key',
  success: function(res) {
    console.log(res.data)
  } 
})

wx.removeStorageSync(KEY)

從本地緩存中同步移除指定 key 。

參數說明:

參數 類型 必填 說明
key String 本地緩存中的指定的 key

示例代碼:

try {
  wx.removeStorageSync('key')
} catch (e) {
  // Do something when catch error
}


易優小程序(企業版)+靈活api+前后代碼開源 碼云倉庫:starfork
本文地址:http://www.xiuhaier.com/wxmini/doc/course/22940.html 復制鏈接 如需定制請聯系易優客服咨詢:800182392 點擊咨詢
QQ在線咨詢
AI智能客服 ×