Home > Web Front-end > uni-app > What to do if uniapp sync cache fails

What to do if uniapp sync cache fails

coldplay.xixi
Release: 2023-01-13 00:44:09
Original
6653 people have browsed it

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)].

What to do if uniapp sync cache fails

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
};
Copy after login

Get

try {
    const value = uni.getStorageSync('storage_key');
    if (value) {
        console.log(value);
    }
} catch (e) {
    // error
};
Copy after login

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
};
Copy after login

Remove the specified key

try {
    uni.removeStorageSync('storage_key');
} catch (e) {
    // error
};
Copy after login

Clear local data cache

try {
    uni.clearStorageSync();
} catch (e) {
    // error
};
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template