swan.removeStorage

    Object object

    图片示例

    swan.removeStorage - 图4

    • 在 js 文件中

    代码示例2 - 业务场景 - 搜索历史

    在开发者工具中预览效果

    • 在 js 文件中
    1. let queryArr = this.getData('queryArr');
    2. if (value) {
    3. const index = queryArr.findIndex(item => item === value);
    4. if (index > -1) {
    5. queryArr.unshift(value);
    6. }
    7. const storeArr = queryArr.slice(0, 20);
    8. },
    9. clearQuery() {
    10. swan.removeStorageSync('queryData');
    11. this.setData('queryArr', []);
    12. }

    iOS