ReferenceError:localStorage未定义文件:“finle:///data/data/org.nativescript/dist/index.js.line 104,column:40 StackTrace:Frame:function:'exports.localStorageSync',file:' file:///data/data/org.nativescript.MyApp/files/app/tns_modules/ngrx-store-localstorage/dist/index.js',line:1010,column:41 Frame:finction:“,file:'文件:///data/data/org.nativescript.MyApp/files/app/core/store/index.js',line:19,列:69
是否必须使用https://www.npmjs.com/package/nativescript-localstorage或我们可以使用https://github.com/natural-apptitude/ngrx-store-ionic-storage或ngrx-store-localstorage
2 回答
NativeScript没有LocalStorage . 你必须安装一个垫片 .
在初始化ngrx之前,在
app.module.ts
的顶部:这应该允许ngrx-store-localstorage工作 .
阅读文档:https://github.com/NathanaelA/nativescript-localstorage
你必须做三个步骤
1安装插件
2在app.module.ts中导入它
3在相应的组件中使用它