Browse Source

:art: https://github.com/Vanessa219/vditor/issues/429

Vanessa 1 year ago
parent
commit
2a2e2767d6
1 changed files with 4 additions and 1 deletions
  1. 4 1
      src/index.ts

+ 4 - 1
src/index.ts

@@ -36,6 +36,7 @@ import {WYSIWYG} from "./ts/wysiwyg/index";
 import {input} from "./ts/wysiwyg/input";
 import {renderDomByMd} from "./ts/wysiwyg/renderDomByMd";
 import {execAfterRender} from "./ts/util/fixBrowserBehavior";
+import {accessLocalStorage} from "./ts/util/compatibility";
 
 class Vditor extends VditorMethod {
     public readonly version: string;
@@ -209,7 +210,9 @@ class Vditor extends VditorMethod {
 
     /** 清除缓存 */
     public clearCache() {
-        localStorage.removeItem(this.vditor.options.cache.id);
+        if (this.vditor.options.cache.enable && accessLocalStorage()) {
+            localStorage.removeItem(this.vditor.options.cache.id);
+        }
     }
 
     /** 禁用缓存 */