【问题标题】:Does amplify.store return error or catch exception when local storage limit exceeded?超出本地存储限制时,amplify.store 是否返回错误或捕获异常?
【发布时间】:2012-09-12 13:30:05
【问题描述】:

有没有办法在这样的调用后检查是否超出本地存储限制:

amplify.store("key", object);

如果我尝试存储大于本地存储限制的内容会怎样?

【问题讨论】:

    标签: jquery amplifyjs


    【解决方案1】:

    是的,它会抛出 "amplify.store quota exceeded" ,您可以在此处看到

    store.error = function() {
        return "amplify.store quota exceeded"; 
    };
    

    ...

    try {
                        storage.setItem( key, parsed );
                    // quota exceeded
                    } catch( error ) {
                        // expire old data and try again
                        store[ storageType ]();
                        try {
                            storage.setItem( key, parsed );
                        } catch( error ) {
                            throw store.error();
                        }
                    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-06-23
      • 1970-01-01
      • 2010-12-14
      • 1970-01-01
      • 2022-12-14
      • 1970-01-01
      • 1970-01-01
      • 2022-11-11
      相关资源
      最近更新 更多