my.getStorage retrieves cached data from local storage. This is an asynchronous interface that supports isolation between embedded webview cache and Mini Program cache. Getting the cache of the specified key of embedded webview will not return the cached data of the same key of the Mini Program.
my.getStorage({
key: 'currentCity',
success: function(res) {
my.alert({content: 'Success' + res.data.cityName});
},
fail: function(res){
my.alert({content: res.errorMessage});
}
});
| Property | Type | Required | Description |
|---|---|---|---|
key | String | Yes | Cache data key. |
success | Function | No | Callback function upon call success. |
fail | Function | No | Callback function upon call failure. |
complete | Function | No | Callback function upon call completion (to be executed upon either call success or failure). |
The incoming parameter is of the Object type with the following attributes:
| Property | Type | Description |
|---|---|---|
data | Object/String | Corresponding content of the key. |
my.setStorage