my.setStorage stores data with a specified key in the local cache. This will overwrite the original data using the same key. This is an asynchronous interface that supports the isolation of webview-embedded storage and the Mini Program storage. Specifying key storage data in embedded webview does not overlap the data corresponding to the same key of the Mini Program itself.
my.setStorage({
key: 'currentCity',
data: {
cityName: 'London',
adCode: '330100',
spell: ' London',
},
success: function() {
my.alert({content: 'Set Success'});
}
});
| Property | Type | Required | Description |
|---|---|---|---|
key | String | Yes | Cache data key. |
data | Object/String | Yes | Data to be cached. |
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). |