HomeDocs
Skip to main content

dlt.setStorage

Introduction

Stores data in the specified key in the local cache. It will overwrite the content corresponding to the key unless the user actively deletes it or the system clears it due to storage space reasons. The data will be available until it is deleted by the user or cleared by the system.

Parameters

Object object

PropertyTypeDefaultRequiredDescription
keystringYesThe key in the local cache where the data will be stored.
datastringYesThe data to be stored. Only native types, Date, and objects that can be serialized using JSON.stringify are supported.
successfunctionNoCallback function for a successful API call.
failfunctionNoCallback function for a failed API call.
completefunctionNoCallback function that will be executed when the API call is complete (both successful and failed calls).

success Callback Function

Parameters

Object res

PropertyTypeDescription
successstringtrue - Set successfully.

fail Callback Function

Parameters

Object res

PropertyTypeDescription
successstringfalse - Set failed.

Example Code

// pages/index/index.js
Page({
setStorage() {
dlt.setStorage({
key: "xxx",
data: "data",
success: function () {
console.log("setStorage success");
},
});
},
});
Privacy agreementDeveloper agreementcontact us: developer_service.mi@transsion.com © 2024 MiniApp. All Rights Reserved.