【发布时间】:2019-04-12 12:42:03
【问题描述】:
我正在尝试在浏览器本地存储中存储一些信息。我的代码在 Chrome 上运行 fine 但是,我在 Firefox 和 Safari 上遇到安全错误和以下警告
Firefox 版本:63.0.1(64 位)
堆栈跟踪:
ERROR DOMException: "The operation is insecure." EventDetailsComponent.html:1
View_EventDetailsComponent_0
EventDetailsComponent.html:1 proxyClass compiler.js:17129
./node_modules/@angular/core/fesm5/core.js/DebugContext_.prototype.logError
core.js:20684
./node_modules/@angular/core/fesm5/core.js/ErrorHandler.prototype.handleError
core.js:12632
./node_modules/@angular/core/fesm5/core.js/ApplicationRef.prototype.tick/<
core.js:14878:54
./node_modules/zone.js/dist/zone.js/</ZoneDelegate.prototype.invoke
zone.js:388
./node_modules/zone.js/dist/zone.js/</Zone.prototype.run
zone.js:138
错误信息:
[WDS] Disconnected! vendor.js:157169:5 close
ERROR DOMException: "The operation is insecure." EventDetailsComponent.html:1
View_EventDetailsComponent_0 EventDetailsComponent.html:1 proxyClass
Request to access cookie or storage on “http://localhost:4200/” was blocked because we are blocking all storage access requests.
本地存储服务:
public getFav(): FavoriteStorage[] {
return JSON.parse(window.localStorage.getItem('favlist'));
}
private setLocalStorageFavList(favL: FavoriteStorage[]): void {
window.localStorage.setItem('favlist', JSON.stringify({ favList: favL }));
}
我试过 localStorage.setItem()/getItem() 而不是 window.localStorage.setItem() /getItem()
【问题讨论】:
标签: angular firefox local-storage