如何查找未定义的本地存储?

问题描述 投票:0回答:1
ERROR ReferenceError: localStorage is not defined
    at _TableComponent.loadUsers (F:\task\training2\src\app\table\table.component.ts:51:30)
    at ToastrService (F:\task\training2\src\app\table\table.component.ts:47:10)
    at callHookInternal (F:\task\training2\.angular\cache\18.2.4\vite\deps_ssr\chunk-S4UJ36BC.js:5640:10)
    at callHook (F:\task\training2\.angular\cache\18.2.4\vite\deps_ssr\chunk-S4UJ36BC.js:5655:7)
    at callHooks (F:\task\training2\.angular\cache\18.2.4\vite\deps_ssr\chunk-S4UJ36BC.js:5629:9)
    at executeInitAndCheckHooks (F:\task\training2\.angular\cache\18.2.4\vite\deps_ssr\chunk-S4UJ36BC.js:5598:5)
    at refreshView (F:\task\training2\.angular\cache\18.2.4\vite\deps_ssr\chunk-S4UJ36BC.js:10505:11)
    at detectChangesInView (F:\task\training2\.angular\cache\18.2.4\vite\deps_ssr\chunk-S4UJ36BC.js:10657:5)
    at detectChangesInViewIfAttached (F:\task\training2\.angular\cache\18.2.4\vite\deps_ssr\chunk-S4UJ36BC.js:10640:3)
    at detectChangesInComponent (F:\task\training2\.angular\cache\18.2.4\vite\deps_ssr\chunk-S4UJ36BC.js:10634:3)

这样来了如何解决

我在期待错误的问题是什么

angular local-storage angular-local-storage angular2-localstorage
1个回答
0
投票

尝试这些方法

语法

window.localStorage

将数据保存到本地存储

localStorage.setItem(key, value);

从本地存储读取数据

let lastname = localStorage.getItem(key);

从本地存储中删除数据

localStorage.removeItem(key);

全部删除(清除本地存储)

localStorage.clear();
© www.soinside.com 2019 - 2024. All rights reserved.