Home > Article > Web Front-end > What to do if uniapp sync cache fails
Solution to uniapp synchronization cache failure: 1. Set the storage, the code is [uni.setStorageSync('storage_key', 'hello')]; 2. Get the relevant information of the current storage, the code is [console. log(res.keys)].
The operating environment of this tutorial: windows7 system, uni-app2.5.1 version, Dell G3 computer. This method is suitable for all brands of computers.
Recommended (free): uni-app development tutorial
Solution to uniapp synchronization cache failure :
Save
try { uni.setStorageSync('storage_key', 'hello'); } catch (e) { // error };
Get
try { const value = uni.getStorageSync('storage_key'); if (value) { console.log(value); } } catch (e) { // error };
Get the relevant information of the current storage
try { const res = uni.getStorageInfoSync(); console.log(res.keys); console.log(res.currentSize); console.log(res.limitSize); } catch (e) { // error };
Remove the specified key
try { uni.removeStorageSync('storage_key'); } catch (e) { // error };
Clear local data cache
try { uni.clearStorageSync(); } catch (e) { // error };
Related free learning recommendations: Programming video
The above is the detailed content of What to do if uniapp sync cache fails. For more information, please follow other related articles on the PHP Chinese website!