全部產品
Search
文件中心

SuperApp:緩衝

更新時間:Oct 29, 2024

本文介紹緩衝WVStorage相關的JS API,供您建立H5端應用或者小程式時參考。緩衝WVStorage的JS API提供資料緩衝相關能力,例如添加緩衝、刪除緩衝、清空緩衝等。

WVStorage.setItem

說明

該API只在Windvane Android 1.0.3.4以上版本有效

將資料存放區在本機快取中指定的key中。

輸入參數

  • [string] key:緩衝的key值。

  • [string] value:緩衝的內容。

回調參數

成功回調參數:

  • 無回調參數。

失敗回調參數:

  • [string] msg:錯誤訊息。

var params = {
  key: 'key',
  value: 'value'
};

window.WindVane.call('WVStorage', 'setItem', params, function(e) {
}, function(e) {
        alert('failure: ' + JSON.stringify(e));
});

WVStorage.getItem

說明

該API只在Windvane Android 1.0.3.4以上版本有效。

擷取指定key值的快取資料。

輸入參數

  • [string] key:指定的key值。

回調參數

成功回調參數:

  • [string] data:key對應的內容。

失敗回調參數:

  • [string] msg:錯誤訊息。

var params = {
  key: 'key'
};

window.WindVane.call('WVStorage', 'getItem', params, function(e) {
        alert('success: ' + JSON.stringify(e));
}, function(e) {
        alert('failure: ' + JSON.stringify(e));
});

WVStorage.removeItem

說明

該API只在Windvane Android 1.0.3.4以上版本有效。

刪除指定key值的快取資料。

輸入參數

  • [string] key:指定的key值。

回調參數

成功回調參數:

  • 無回調參數。

失敗回調參數:

  • [string] msg:錯誤訊息。

var params = {
  key: 'key'
};

window.WindVane.call('WVStorage', 'removeItem', params, function(e) {
}, function(e) {
        alert('failure: ' + JSON.stringify(e));
});

WVStorage.clearStorage

說明

該API只在Windvane Android 1.0.3.4以上版本有效。

清除本機資料緩衝(非同步執行)。

輸入參數

  • 無輸入參數。

回調參數

成功回調參數:

  • 無回調參數。

失敗回調參數:

  • [string] msg:錯誤訊息。

window.WindVane.call('WVStorage', 'clearStorage', {}, function(e) {
}, function(e) {
        alert('failure: ' + JSON.stringify(e));
});

WVStorage.clearStorageSync

說明

該API只在Windvane Android 1.0.3.4以上版本有效。

清除本機資料緩衝(同步執行)。

輸入參數

  • 無輸入參數。

回調參數

成功回調參數:

  • 無回調參數。

失敗回調參數:

  • [string] msg:錯誤訊息。

window.WindVane.call('WVStorage', 'clearStorageSync', {}, function(e) {
}, function(e) {
        alert('failure: ' + JSON.stringify(e));
});